Browse Source

Remove unneeded SDKs and Scripts directories

Branan Purvine-Riley 13 years ago
parent
commit
e825206eb6
  1. BIN
      SDKs/Win32/HawkVoice/lib/HawkVoiceDIstatic.lib
  2. 122
      SDKs/Win32/HawkVoice/src/BLOWFISH/Blowfish.001
  3. 128
      SDKs/Win32/HawkVoice/src/BLOWFISH/Blowfish.dsp
  4. 46
      SDKs/Win32/HawkVoice/src/BLOWFISH/COPYRIGHT
  5. 14
      SDKs/Win32/HawkVoice/src/BLOWFISH/INSTALL
  6. 160
      SDKs/Win32/HawkVoice/src/BLOWFISH/Makefile
  7. 104
      SDKs/Win32/HawkVoice/src/BLOWFISH/Makefile.ssl
  8. 160
      SDKs/Win32/HawkVoice/src/BLOWFISH/Makefile.uni
  9. 8
      SDKs/Win32/HawkVoice/src/BLOWFISH/README
  10. 159
      SDKs/Win32/HawkVoice/src/BLOWFISH/asm/bf586.pl
  11. 666
      SDKs/Win32/HawkVoice/src/BLOWFISH/asm/bx86-cpp.s
  12. 33
      SDKs/Win32/HawkVoice/src/BLOWFISH/asm/bx86unix.cpp
  13. 3
      SDKs/Win32/HawkVoice/src/BLOWFISH/asm/readme
  14. 663
      SDKs/Win32/HawkVoice/src/BLOWFISH/asm/win32.asm
  15. 249
      SDKs/Win32/HawkVoice/src/BLOWFISH/asm/x86ms.pl
  16. 313
      SDKs/Win32/HawkVoice/src/BLOWFISH/asm/x86unix.pl
  17. 143
      SDKs/Win32/HawkVoice/src/BLOWFISH/bf_cbc.c
  18. 122
      SDKs/Win32/HawkVoice/src/BLOWFISH/bf_cfb64.c
  19. 91
      SDKs/Win32/HawkVoice/src/BLOWFISH/bf_ecb.c
  20. 137
      SDKs/Win32/HawkVoice/src/BLOWFISH/bf_enc.c
  21. 236
      SDKs/Win32/HawkVoice/src/BLOWFISH/bf_locl.h
  22. 215
      SDKs/Win32/HawkVoice/src/BLOWFISH/bf_locl.org
  23. 110
      SDKs/Win32/HawkVoice/src/BLOWFISH/bf_ofb64.c
  24. 325
      SDKs/Win32/HawkVoice/src/BLOWFISH/bf_pi.h
  25. 116
      SDKs/Win32/HawkVoice/src/BLOWFISH/bf_skey.c
  26. 149
      SDKs/Win32/HawkVoice/src/BLOWFISH/blowfish.doc
  27. 114
      SDKs/Win32/HawkVoice/src/BLOWFISH/blowfish.h
  28. 194
      SDKs/Win32/HawkVoice/src/hvdi.h
  29. 3
      SDKs/XPlatform/Cypython-2.3.3/Grammar/.cvsignore
  30. 107
      SDKs/XPlatform/Cypython-2.3.3/Grammar/Grammar
  31. 262
      SDKs/XPlatform/Cypython-2.3.3/LICENSE
  32. 9
      SDKs/XPlatform/Cypython-2.3.3/Modules/.cvsignore
  33. 13
      SDKs/XPlatform/Cypython-2.3.3/Modules/Setup.config.in
  34. 486
      SDKs/XPlatform/Cypython-2.3.3/Modules/Setup.dist
  35. 4715
      SDKs/XPlatform/Cypython-2.3.3/Modules/_bsddb.c
  36. 816
      SDKs/XPlatform/Cypython-2.3.3/Modules/_codecsmodule.c
  37. 1556
      SDKs/XPlatform/Cypython-2.3.3/Modules/_csv.c
  38. 471
      SDKs/XPlatform/Cypython-2.3.3/Modules/_curses_panel.c
  39. 2595
      SDKs/XPlatform/Cypython-2.3.3/Modules/_cursesmodule.c
  40. 1666
      SDKs/XPlatform/Cypython-2.3.3/Modules/_hotshot.c
  41. 783
      SDKs/XPlatform/Cypython-2.3.3/Modules/_localemodule.c
  42. 531
      SDKs/XPlatform/Cypython-2.3.3/Modules/_randommodule.c
  43. 3166
      SDKs/XPlatform/Cypython-2.3.3/Modules/_sre.c
  44. 639
      SDKs/XPlatform/Cypython-2.3.3/Modules/_ssl.c
  45. 642
      SDKs/XPlatform/Cypython-2.3.3/Modules/_testcapimodule.c
  46. 3203
      SDKs/XPlatform/Cypython-2.3.3/Modules/_tkinter.c
  47. 131
      SDKs/XPlatform/Cypython-2.3.3/Modules/_weakref.c
  48. 176
      SDKs/XPlatform/Cypython-2.3.3/Modules/addrinfo.h
  49. 3222
      SDKs/XPlatform/Cypython-2.3.3/Modules/almodule.c
  50. 73
      SDKs/XPlatform/Cypython-2.3.3/Modules/ar_beos
  51. 2037
      SDKs/XPlatform/Cypython-2.3.3/Modules/arraymodule.c
  52. 1381
      SDKs/XPlatform/Cypython-2.3.3/Modules/audioop.c
  53. 1337
      SDKs/XPlatform/Cypython-2.3.3/Modules/binascii.c
  54. 856
      SDKs/XPlatform/Cypython-2.3.3/Modules/bsddbmodule.c
  55. 2191
      SDKs/XPlatform/Cypython-2.3.3/Modules/bz2module.c
  56. 5761
      SDKs/XPlatform/Cypython-2.3.3/Modules/cPickle.c
  57. 731
      SDKs/XPlatform/Cypython-2.3.3/Modules/cStringIO.c
  58. 11
      SDKs/XPlatform/Cypython-2.3.3/Modules/ccpython.cc
  59. 794
      SDKs/XPlatform/Cypython-2.3.3/Modules/cdmodule.c
  60. 520
      SDKs/XPlatform/Cypython-2.3.3/Modules/cgen.py
  61. 310
      SDKs/XPlatform/Cypython-2.3.3/Modules/cgensupport.c
  62. 64
      SDKs/XPlatform/Cypython-2.3.3/Modules/cgensupport.h
  63. 2557
      SDKs/XPlatform/Cypython-2.3.3/Modules/clmodule.c
  64. 404
      SDKs/XPlatform/Cypython-2.3.3/Modules/cmathmodule.c
  65. 48
      SDKs/XPlatform/Cypython-2.3.3/Modules/config.c.in
  66. 44
      SDKs/XPlatform/Cypython-2.3.3/Modules/cryptmodule.c
  67. 1364
      SDKs/XPlatform/Cypython-2.3.3/Modules/cstubs
  68. 4854
      SDKs/XPlatform/Cypython-2.3.3/Modules/datetimemodule.c
  69. 372
      SDKs/XPlatform/Cypython-2.3.3/Modules/dbmmodule.c
  70. 254
      SDKs/XPlatform/Cypython-2.3.3/Modules/dlmodule.c
  71. 795
      SDKs/XPlatform/Cypython-2.3.3/Modules/errnomodule.c
  72. 158
      SDKs/XPlatform/Cypython-2.3.3/Modules/expat/Makefile.in
  73. 85
      SDKs/XPlatform/Cypython-2.3.3/Modules/expat/ascii.h
  74. 36
      SDKs/XPlatform/Cypython-2.3.3/Modules/expat/asciitab.h
  75. 1001
      SDKs/XPlatform/Cypython-2.3.3/Modules/expat/expat.h
  76. 37
      SDKs/XPlatform/Cypython-2.3.3/Modules/expat/iasciitab.h
  77. 73
      SDKs/XPlatform/Cypython-2.3.3/Modules/expat/internal.h
  78. 36
      SDKs/XPlatform/Cypython-2.3.3/Modules/expat/latin1tab.h
  79. 104
      SDKs/XPlatform/Cypython-2.3.3/Modules/expat/macconfig.h
  80. 150
      SDKs/XPlatform/Cypython-2.3.3/Modules/expat/nametab.h
  81. 37
      SDKs/XPlatform/Cypython-2.3.3/Modules/expat/utf8tab.h
  82. 30
      SDKs/XPlatform/Cypython-2.3.3/Modules/expat/winconfig.h
  83. 5814
      SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmlparse.c
  84. 1323
      SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmlrole.c
  85. 114
      SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmlrole.h
  86. 1634
      SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmltok.c
  87. 315
      SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmltok.h
  88. 1779
      SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmltok_impl.c
  89. 46
      SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmltok_impl.h
  90. 106
      SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmltok_ns.c
  91. 594
      SDKs/XPlatform/Cypython-2.3.3/Modules/fcntlmodule.c
  92. 2138
      SDKs/XPlatform/Cypython-2.3.3/Modules/flmodule.c
  93. 262
      SDKs/XPlatform/Cypython-2.3.3/Modules/fmmodule.c
  94. 276
      SDKs/XPlatform/Cypython-2.3.3/Modules/fpectlmodule.c
  95. 184
      SDKs/XPlatform/Cypython-2.3.3/Modules/fpetestmodule.c
  96. 107
      SDKs/XPlatform/Cypython-2.3.3/Modules/gc_weakref.txt
  97. 1232
      SDKs/XPlatform/Cypython-2.3.3/Modules/gcmodule.c
  98. 523
      SDKs/XPlatform/Cypython-2.3.3/Modules/gdbmmodule.c
  99. 638
      SDKs/XPlatform/Cypython-2.3.3/Modules/getaddrinfo.c
  100. 38
      SDKs/XPlatform/Cypython-2.3.3/Modules/getbuildinfo.c
  101. Some files were not shown because too many files have changed in this diff Show More

BIN
SDKs/Win32/HawkVoice/lib/HawkVoiceDIstatic.lib

Binary file not shown.

122
SDKs/Win32/HawkVoice/src/BLOWFISH/Blowfish.001

@ -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

128
SDKs/Win32/HawkVoice/src/BLOWFISH/Blowfish.dsp

@ -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

46
SDKs/Win32/HawkVoice/src/BLOWFISH/COPYRIGHT

@ -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.

14
SDKs/Win32/HawkVoice/src/BLOWFISH/INSTALL

@ -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

160
SDKs/Win32/HawkVoice/src/BLOWFISH/Makefile

@ -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.

104
SDKs/Win32/HawkVoice/src/BLOWFISH/Makefile.ssl

@ -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.

160
SDKs/Win32/HawkVoice/src/BLOWFISH/Makefile.uni

@ -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.

8
SDKs/Win32/HawkVoice/src/BLOWFISH/README

@ -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

159
SDKs/Win32/HawkVoice/src/BLOWFISH/asm/bf586.pl

@ -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 <eay\@mincom.oz.au>");
&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]);
}

666
SDKs/Win32/HawkVoice/src/BLOWFISH/asm/bx86-cpp.s

@ -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 <eay@mincom.oz.au> */
.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"

33
SDKs/Win32/HawkVoice/src/BLOWFISH/asm/bx86unix.cpp

@ -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"

3
SDKs/Win32/HawkVoice/src/BLOWFISH/asm/readme

@ -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.

663
SDKs/Win32/HawkVoice/src/BLOWFISH/asm/win32.asm

@ -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 <eay@mincom.oz.au>
;
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

249
SDKs/Win32/HawkVoice/src/BLOWFISH/asm/x86ms.pl

@ -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";
}

313
SDKs/Win32/HawkVoice/src/BLOWFISH/asm/x86unix.pl

@ -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
{
}

143
SDKs/Win32/HawkVoice/src/BLOWFISH/bf_cbc.c

@ -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;
}

122
SDKs/Win32/HawkVoice/src/BLOWFISH/bf_cfb64.c

@ -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;
}

91
SDKs/Win32/HawkVoice/src/BLOWFISH/bf_ecb.c

@ -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;
}

137
SDKs/Win32/HawkVoice/src/BLOWFISH/bf_enc.c

@ -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;
}

236
SDKs/Win32/HawkVoice/src/BLOWFISH/bf_locl.h

@ -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_3; \
u&=BF_M; \
v&=BF_M; \
t^= *(BF_LONG *)((unsigned char *)&(S[512])+u); \
LL^=P; \
t+= *(BF_LONG *)((unsigned char *)&(S[768])+v); \
LL^=t; \
}
#elif defined(BF_PTR)
/* This is normally very good */
#define BF_ENC(LL,R,S,P) \
LL^=P; \
LL^= (((*(BF_LONG *)((unsigned char *)&(S[ 0])+((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<<BF_3)&BF_M)));
#else
/* This will always work, even on 64 bit machines and strangly enough,
* on the Alpha it is faster than the pointer versions (both 32 and 64
* versions of BF_LONG) */
#define BF_ENC(LL,R,S,P) \
LL^=P; \
LL^=((( S[ (R>>24L) ] + \
S[0x0100+((R>>16L)&0xff)])^ \
S[0x0200+((R>> 8L)&0xff)])+ \
S[0x0300+((R )&0xff)])&0xffffffff;
#endif

215
SDKs/Win32/HawkVoice/src/BLOWFISH/bf_locl.org

@ -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_3; \
u&=BF_M; \
v&=BF_M; \
t^= *(BF_LONG *)((unsigned char *)&(S[512])+u); \
LL^=P; \
t+= *(BF_LONG *)((unsigned char *)&(S[768])+v); \
LL^=t; \
}
#elif defined(BF_PTR)
/* This is normally very good */
#define BF_ENC(LL,R,S,P) \
LL^=P; \
LL^= (((*(BF_LONG *)((unsigned char *)&(S[ 0])+((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<<BF_3)&BF_M)));
#else
/* This will always work, even on 64 bit machines and strangly enough,
* on the Alpha it is faster than the pointer versions (both 32 and 64
* versions of BF_LONG) */
#define BF_ENC(LL,R,S,P) \
LL^=P; \
LL^=((( S[ (R>>24L) ] + \
S[0x0100+((R>>16L)&0xff)])^ \
S[0x0200+((R>> 8L)&0xff)])+ \
S[0x0300+((R )&0xff)])&0xffffffff;
#endif

110
SDKs/Win32/HawkVoice/src/BLOWFISH/bf_ofb64.c

@ -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;
}

325
SDKs/Win32/HawkVoice/src/BLOWFISH/bf_pi.h

@ -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,
}
};

116
SDKs/Win32/HawkVoice/src/BLOWFISH/bf_skey.c

@ -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 <stdio.h>
#include <string.h>
#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];
}
}

149
SDKs/Win32/HawkVoice/src/BLOWFISH/blowfish.doc

@ -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.

114
SDKs/Win32/HawkVoice/src/BLOWFISH/blowfish.h

@ -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

194
SDKs/Win32/HawkVoice/src/hvdi.h

@ -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 */

3
SDKs/XPlatform/Cypython-2.3.3/Grammar/.cvsignore

@ -1,3 +0,0 @@
graminit.h
graminit.c
Makefile

107
SDKs/XPlatform/Cypython-2.3.3/Grammar/Grammar

@ -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 <fdrake@acm.org> 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

262
SDKs/XPlatform/Cypython-2.3.3/LICENSE

@ -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.

9
SDKs/XPlatform/Cypython-2.3.3/Modules/.cvsignore

@ -1,9 +0,0 @@
Setup
Makefile.pre
Setup.thread
Setup.config
Setup.local
hassignal
config.c
Makefile
add2lib

13
SDKs/XPlatform/Cypython-2.3.3/Modules/Setup.config.in

@ -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.

486
SDKs/XPlatform/Cypython-2.3.3/Modules/Setup.dist

@ -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:
#
# <module> ... [<sourcefile> ...] [<cpparg> ...] [<library> ...]
#
# <sourcefile> is anything ending in .c (.C, .cc, .c++ are C++ files)
# <cpparg> is anything starting with -I, -D, -U or -C
# <library> is anything ending in .a or beginning with -l or -L
# <module> 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
#
# <name> = <value>
#
# 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 <http://www.sleepycat.com/>.
#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

4715
SDKs/XPlatform/Cypython-2.3.3/Modules/_bsddb.c

File diff suppressed because it is too large Load Diff

816
SDKs/XPlatform/Cypython-2.3.3/Modules/_codecsmodule.c

@ -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:
<encoding>_encode(Unicode_object[,errors='strict']) ->
(string object, bytes consumed)
<encoding>_decode(char_buffer_obj[,errors='strict']) ->
(Unicode object, bytes consumed)
<encoding>_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 <encoding>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);
}

1556
SDKs/XPlatform/Cypython-2.3.3/Modules/_csv.c

File diff suppressed because it is too large Load Diff

471
SDKs/XPlatform/Cypython-2.3.3/Modules/_curses_panel.c

@ -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 <panel.h>
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);
}

2595
SDKs/XPlatform/Cypython-2.3.3/Modules/_cursesmodule.c

File diff suppressed because it is too large Load Diff

1666
SDKs/XPlatform/Cypython-2.3.3/Modules/_hotshot.c

File diff suppressed because it is too large Load Diff

783
SDKs/XPlatform/Cypython-2.3.3/Modules/_localemodule.c

@ -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 <stdio.h>
#include <errno.h>
#include <locale.h>
#include <string.h>
#include <ctype.h>
#ifdef HAVE_LANGINFO_H
#include <langinfo.h>
#endif
#ifdef HAVE_LIBINTL_H
#include <libintl.h>
#endif
#ifdef HAVE_WCHAR_H
#include <wchar.h>
#endif
#if defined(MS_WINDOWS)
#ifdef MS_XBOX
#include <xtl.h>
#else
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#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:
*/

531
SDKs/XPlatform/Cypython-2.3.3/Modules/_randommodule.c

@ -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 <time.h> /* 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<N-M;kk++) {
y = (mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK);
mt[kk] = mt[kk+M] ^ (y >> 1) ^ mag01[y & 0x1UL];
}
for (;kk<N-1;kk++) {
y = (mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK);
mt[kk] = mt[kk+(M-N)] ^ (y >> 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<N; mti++) {
mt[mti] =
(1812433253UL * (mt[mti-1] ^ (mt[mti-1] >> 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; i<N ; i++) {
element = PyInt_FromLong((long)(self->state[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; i<N ; i++) {
element = PyInt_AsLong(PyTuple_GET_ITEM(state, i));
if (element == -1 && PyErr_Occurred())
return NULL;
self->state[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);
}

3166
SDKs/XPlatform/Cypython-2.3.3/Modules/_sre.c

File diff suppressed because it is too large Load Diff

639
SDKs/XPlatform/Cypython-2.3.3/Modules/_ssl.c

@ -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);
}

642
SDKs/XPlatform/Cypython-2.3.3/Modules/_testcapimodule.c

@ -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 <wink>
*/
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);
}

3203
SDKs/XPlatform/Cypython-2.3.3/Modules/_tkinter.c

File diff suppressed because it is too large Load Diff

131
SDKs/XPlatform/Cypython-2.3.3/Modules/_weakref.c

@ -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);
}
}

176
SDKs/XPlatform/Cypython-2.3.3/Modules/addrinfo.h

@ -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

3222
SDKs/XPlatform/Cypython-2.3.3/Modules/almodule.c

File diff suppressed because it is too large Load Diff

73
SDKs/XPlatform/Cypython-2.3.3/Modules/ar_beos

@ -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

2037
SDKs/XPlatform/Cypython-2.3.3/Modules/arraymodule.c

File diff suppressed because it is too large Load Diff

1381
SDKs/XPlatform/Cypython-2.3.3/Modules/audioop.c

File diff suppressed because it is too large Load Diff

1337
SDKs/XPlatform/Cypython-2.3.3/Modules/binascii.c

File diff suppressed because it is too large Load Diff

856
SDKs/XPlatform/Cypython-2.3.3/Modules/bsddbmodule.c

@ -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 <niemeyer@conectiva.com> 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 <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#ifdef HAVE_DB_185_H
#include <db_185.h>
#else
#include <db.h>
#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);
}

2191
SDKs/XPlatform/Cypython-2.3.3/Modules/bz2module.c

File diff suppressed because it is too large Load Diff

5761
SDKs/XPlatform/Cypython-2.3.3/Modules/cPickle.c

File diff suppressed because it is too large Load Diff

731
SDKs/XPlatform/Cypython-2.3.3/Modules/cStringIO.c

@ -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;
}

11
SDKs/XPlatform/Cypython-2.3.3/Modules/ccpython.cc

@ -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);
}

794
SDKs/XPlatform/Cypython-2.3.3/Modules/cdmodule.c

@ -1,794 +0,0 @@
/* CD module -- interface to Mark Callow's and Roger Chickering's */
/* CD Audio Library (CD). */
#include <sys/types.h>
#include <cdaudio.h>
#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
}

520
SDKs/XPlatform/Cypython-2.3.3/Modules/cgen.py

@ -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 <cstubs >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 mknew<type>object(<arg>)
#
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 '%%'.
# <part1> -- literally copied to stdout
# <part2> -- 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 '}'

310
SDKs/XPlatform/Cypython-2.3.3/Modules/cgensupport.c

@ -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();
}
}

64
SDKs/XPlatform/Cypython-2.3.3/Modules/cgensupport.h

@ -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 */

2557
SDKs/XPlatform/Cypython-2.3.3/Modules/clmodule.c

File diff suppressed because it is too large Load Diff

404
SDKs/XPlatform/Cypython-2.3.3/Modules/cmathmodule.c

@ -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)));
}

48
SDKs/XPlatform/Cypython-2.3.3/Modules/config.c.in

@ -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}
};

44
SDKs/XPlatform/Cypython-2.3.3/Modules/cryptmodule.c

@ -1,44 +0,0 @@
/* cryptmodule.c - by Steve Majewski
*/
#include "Python.h"
#include <sys/types.h>
/* 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);
}

1364
SDKs/XPlatform/Cypython-2.3.3/Modules/cstubs

File diff suppressed because it is too large Load Diff

4854
SDKs/XPlatform/Cypython-2.3.3/Modules/datetimemodule.c

File diff suppressed because it is too large Load Diff

372
SDKs/XPlatform/Cypython-2.3.3/Modules/dbmmodule.c

@ -1,372 +0,0 @@
/* DBM module using dictionary interface */
#include "Python.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
/* 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 <ndbm.h>
#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 <gdbm/ndbm.h>
static char *which_dbm = "GNU gdbm";
#elif defined(HAVE_BERKDB_H)
#include <db.h>
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);
}

254
SDKs/XPlatform/Cypython-2.3.3/Modules/dlmodule.c

@ -1,254 +0,0 @@
/* dl module */
#include "Python.h"
#include <dlfcn.h>
#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
}

795
SDKs/XPlatform/Cypython-2.3.3/Modules/errnomodule.c

@ -1,795 +0,0 @@
/* Errno module */
#include "Python.h"
/* Mac with GUSI has more errors than those in errno.h */
#ifdef USE_GUSI
#include <sys/errno.h>
#endif
/* Windows socket errors (WSA*) */
#ifdef MS_WINDOWS
#ifdef MS_XBOX
#include <xtl.h>
#else
#include <winsock.h>
#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);
}

158
SDKs/XPlatform/Cypython-2.3.3/Modules/expat/Makefile.in

@ -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

85
SDKs/XPlatform/Cypython-2.3.3/Modules/expat/ascii.h

@ -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

36
SDKs/XPlatform/Cypython-2.3.3/Modules/expat/asciitab.h

@ -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,

1001
SDKs/XPlatform/Cypython-2.3.3/Modules/expat/expat.h

File diff suppressed because it is too large Load Diff

37
SDKs/XPlatform/Cypython-2.3.3/Modules/expat/iasciitab.h

@ -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,

73
SDKs/XPlatform/Cypython-2.3.3/Modules/expat/internal.h

@ -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

36
SDKs/XPlatform/Cypython-2.3.3/Modules/expat/latin1tab.h

@ -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,

104
SDKs/XPlatform/Cypython-2.3.3/Modules/expat/macconfig.h

@ -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 <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define to 1 if you have the <fcntl.h> 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 <inttypes.h> 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 <memory.h> 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 <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> 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 <sys/types.h> does not define. */
#define off_t long
/* Define to `unsigned' if <sys/types.h> does not define. */
#undef size_t
#endif /* ifndef MACCONFIG_H */

150
SDKs/XPlatform/Cypython-2.3.3/Modules/expat/nametab.h

@ -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,
};

37
SDKs/XPlatform/Cypython-2.3.3/Modules/expat/utf8tab.h

@ -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,

30
SDKs/XPlatform/Cypython-2.3.3/Modules/expat/winconfig.h

@ -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 <windows.h>
#undef WIN32_LEAN_AND_MEAN
#include <memory.h>
#include <string.h>
#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 */

5814
SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmlparse.c

File diff suppressed because it is too large Load Diff

1323
SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmlrole.c

File diff suppressed because it is too large Load Diff

114
SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmlrole.h

@ -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 */

1634
SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmltok.c

File diff suppressed because it is too large Load Diff

315
SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmltok.h

@ -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 <e/> */
#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 /* <!foo */
#define XML_TOK_DECL_CLOSE 17 /* > */
#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_COND_SECT_CLOSE 34 /* ]]> */
#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 */

1779
SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmltok_impl.c

File diff suppressed because it is too large Load Diff

46
SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmltok_impl.h

@ -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 <stddef.h>

106
SDKs/XPlatform/Cypython-2.3.3/Modules/expat/xmltok_ns.c

@ -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);
}

594
SDKs/XPlatform/Cypython-2.3.3/Modules/fcntlmodule.c

@ -1,594 +0,0 @@
/* fcntl module */
#include "Python.h"
#ifdef HAVE_SYS_FILE_H
#include <sys/file.h>
#endif
#include <sys/ioctl.h>
#include <fcntl.h>
#ifdef HAVE_STROPTS_H
#include <stropts.h>
#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);
}

2138
SDKs/XPlatform/Cypython-2.3.3/Modules/flmodule.c

File diff suppressed because it is too large Load Diff

262
SDKs/XPlatform/Cypython-2.3.3/Modules/fmmodule.c

@ -1,262 +0,0 @@
/* Font Manager module */
#include "Python.h"
#include <gl.h>
#include <device.h>
#include <fmclient.h>
/* 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();
}

276
SDKs/XPlatform/Cypython-2.3.3/Modules/fpectlmodule.c

@ -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 <signal.h>
#if defined(__FreeBSD__)
# include <ieeefp.h>
#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 <setjmp.h>
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 <sigfpe.h>
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 <math.h>
#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 <math.h>
fpsetdefaults();
PyOS_setsig(SIGFPE, handler);
/*-- IBM AIX --------------------------------------------------------------*/
#elif defined(__AIX) || defined(_AIX)
/* References: fp_trap, fp_enable man pages */
#include <fptrap.h>
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 <machine/fpu.h>
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 <asm/fpu.h>
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 <fpu_control.h>
#else
#include <i386/fpu_control.h>
#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 <float.h>
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

184
SDKs/XPlatform/Cypython-2.3.3/Modules/fpetestmodule.c

@ -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);
}

107
SDKs/XPlatform/Cypython-2.3.3/Modules/gc_weakref.txt

@ -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.

1232
SDKs/XPlatform/Cypython-2.3.3/Modules/gcmodule.c

File diff suppressed because it is too large Load Diff

523
SDKs/XPlatform/Cypython-2.3.3/Modules/gdbmmodule.c

@ -1,523 +0,0 @@
/* DBM module using dictionary interface */
/* Author: Anthony Baxter, after dbmmodule.c */
/* Doc strings: Mitch Chapman */
#include "Python.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#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);
}
}

638
SDKs/XPlatform/Cypython-2.3.3/Modules/getaddrinfo.c

@ -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 <sys/types.h>
#include <sys/param.h>
#include <sys/sysctl.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <arpa/nameser.h>
#include <netdb.h>
#include <resolv.h>
#include <string.h>
#include <stdlib.h>
#include <stddef.h>
#include <ctype.h>
#include <unistd.h>
#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;
}

38
SDKs/XPlatform/Cypython-2.3.3/Modules/getbuildinfo.c

@ -1,38 +0,0 @@
#include "Python.h"
#ifdef macintosh
#include "macbuildno.h"
#endif
#ifndef DONT_HAVE_STDIO_H
#include <stdio.h>
#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;
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save