summaryrefslogtreecommitdiffstats
path: root/Lib/irix5
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1993-12-29 16:35:41 (GMT)
committerGuido van Rossum <guido@python.org>1993-12-29 16:35:41 (GMT)
commit70f1418d35e7131a171ba872777074dab02e13d6 (patch)
treeaf1a5082f6970d16b7db7b9694d10c86f10b9eb3 /Lib/irix5
parentdd8cb446e19cb24131227bd66aa690b34e64a75a (diff)
downloadcpython-70f1418d35e7131a171ba872777074dab02e13d6.zip
cpython-70f1418d35e7131a171ba872777074dab02e13d6.tar.gz
cpython-70f1418d35e7131a171ba872777074dab02e13d6.tar.bz2
New files (not really...)
Diffstat (limited to 'Lib/irix5')
-rwxr-xr-xLib/irix5/FCNTL.py49
-rwxr-xr-xLib/irix5/IN.py59
-rwxr-xr-xLib/irix5/IOCTL.py233
-rwxr-xr-xLib/irix5/SOCKET.py77
-rwxr-xr-xLib/irix5/jpeg.py110
5 files changed, 528 insertions, 0 deletions
diff --git a/Lib/irix5/FCNTL.py b/Lib/irix5/FCNTL.py
new file mode 100755
index 0000000..1271b9e
--- /dev/null
+++ b/Lib/irix5/FCNTL.py
@@ -0,0 +1,49 @@
+# These lines were generated by h2py.py (see demo/scripts)
+# from <sys/fcntl.h> on Irix 4.0.2.
+# The applicability on other systems is not clear.
+
+FNDELAY = 0x04
+FAPPEND = 0x08
+FSYNC = 0x10
+FRCACH = 0x20
+FASYNC = 0x40
+FNONBLK = 0x80
+FCREAT = 0x100
+FTRUNC = 0x200
+FEXCL = 0x400
+FNOCTTY = 0x800
+O_RDONLY = 0
+O_WRONLY = 1
+O_RDWR = 2
+O_ACCMODE = 0x3
+O_NDELAY = FNDELAY
+O_APPEND = FAPPEND
+O_SYNC = FSYNC
+O_NONBLOCK = FNONBLK
+O_CREAT = FCREAT
+O_TRUNC = FTRUNC
+O_EXCL = FEXCL
+O_NOCTTY = FNOCTTY
+F_DUPFD = 0
+F_GETFD = 1
+F_SETFD = 2
+F_GETFL = 3
+F_SETFL = 4
+F_GETLK = 5
+F_SETLK = 6
+F_SETLKW = 7
+F_CHKFL = 8
+F_ALLOCSP = 10
+F_FREESP = 11
+F_SETBSDLK = 12
+F_SETBSDLKW = 13
+F_RGETLK = 20
+F_RSETLK = 21
+F_RSETLKW = 22
+F_GETOWN = 10
+F_SETOWN = 11
+F_RDLCK = 01
+F_WRLCK = 02
+F_UNLCK = 03
+FD_CLOEXEC = 0x1
+FD_NODUP_FORK = 0x2
diff --git a/Lib/irix5/IN.py b/Lib/irix5/IN.py
new file mode 100755
index 0000000..78be3ef
--- /dev/null
+++ b/Lib/irix5/IN.py
@@ -0,0 +1,59 @@
+# Symbolic constants from <netinet/in.h>.
+# These constants are SGI specific!
+# See demo/scripts/h2py.py for a tool to help generate a version for
+# your system.
+
+IPPROTO_IP = 0
+IPPROTO_ICMP = 1
+IPPROTO_IGMP = 2
+IPPROTO_GGP = 3
+IPPROTO_TCP = 6
+IPPROTO_EGP = 8
+IPPROTO_PUP = 12
+IPPROTO_UDP = 17
+IPPROTO_IDP = 22
+IPPROTO_TP = 29
+IPPROTO_XTP = 36
+IPPROTO_EON = 80
+IPPROTO_RAW = 255
+IPPROTO_MAX = 256
+IPPORT_RESERVED = 1024
+IPPORT_USERRESERVED = 5000
+IN_CLASSA_NET = 0xff000000
+IN_CLASSA_NSHIFT = 24
+IN_CLASSA_HOST = 0x00ffffff
+IN_CLASSA_MAX = 128
+IN_CLASSB_NET = 0xffff0000
+IN_CLASSB_NSHIFT = 16
+IN_CLASSB_HOST = 0x0000ffff
+IN_CLASSB_MAX = 65536
+IN_CLASSC_NET = 0xffffff00
+IN_CLASSC_NSHIFT = 8
+IN_CLASSC_HOST = 0x000000ff
+IN_CLASSD_NET = 0xf0000000
+IN_CLASSD_NSHIFT = 28
+IN_CLASSD_HOST = 0x0fffffff
+INADDR_ANY = 0x00000000
+INADDR_BROADCAST = 0xffffffff
+INADDR_LOOPBACK = 0x7F000001
+INADDR_UNSPEC_GROUP = 0xe0000000
+INADDR_ALLHOSTS_GROUP = 0xe0000001
+INADDR_MAX_LOCAL_GROUP = 0xe00000ff
+INADDR_NONE = 0xffffffff
+IN_LOOPBACKNET = 127
+IP_OPTIONS = 1
+IP_HDRINCL = 7
+IP_TOS = 8
+IP_TTL = 9
+IP_RECVOPTS = 10
+IP_RECVRETOPTS = 11
+IP_RECVDSTADDR = 12
+IP_RETOPTS = 13
+IP_MULTICAST_IF = 2
+IP_MULTICAST_TTL = 3
+IP_MULTICAST_LOOP = 4
+IP_ADD_MEMBERSHIP = 5
+IP_DROP_MEMBERSHIP = 6
+IP_DEFAULT_MULTICAST_TTL = 1
+IP_DEFAULT_MULTICAST_LOOP = 1
+IP_MAX_MEMBERSHIPS = 20
diff --git a/Lib/irix5/IOCTL.py b/Lib/irix5/IOCTL.py
new file mode 100755
index 0000000..cec3c3f
--- /dev/null
+++ b/Lib/irix5/IOCTL.py
@@ -0,0 +1,233 @@
+# These lines were mostly generated by h2py.py (see demo/scripts)
+# from <sys/ioctl.h>, <sys/termio.h> and <termios.h> on Irix 4.0.2
+# with some manual changes to cope with imperfections in h2py.py.
+# The applicability on other systems is not clear; especially non-SYSV
+# systems may have a totally different set of ioctls.
+
+IOCTYPE = 0xff00
+LIOC = (ord('l')<<8)
+LIOCGETP = (LIOC|1)
+LIOCSETP = (LIOC|2)
+LIOCGETS = (LIOC|5)
+LIOCSETS = (LIOC|6)
+DIOC = (ord('d')<<8)
+DIOCGETC = (DIOC|1)
+DIOCGETB = (DIOC|2)
+DIOCSETE = (DIOC|3)
+IOCPARM_MASK = 0x7f
+IOC_VOID = 0x20000000
+IOC_OUT = 0x40000000
+IOC_IN = 0x80000000
+IOC_INOUT = (IOC_IN|IOC_OUT)
+int = 'i'
+short = 'h'
+long = 'l'
+def sizeof(t): import struct; return struct.calcsize(t)
+def _IO(x,y): return (IOC_VOID|((x)<<8)|y)
+def _IOR(x,y,t): return (IOC_OUT|((sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|y)
+def _IOW(x,y,t): return (IOC_IN|((sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|y)
+# this should be _IORW, but stdio got there first
+def _IOWR(x,y,t): return (IOC_INOUT|((sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|y)
+FIONREAD = _IOR(ord('f'), 127, int)
+FIONBIO = _IOW(ord('f'), 126, int)
+FIOASYNC = _IOW(ord('f'), 125, int)
+FIOSETOWN = _IOW(ord('f'), 124, int)
+FIOGETOWN = _IOR(ord('f'), 123, int)
+NCC = 8
+NCC_PAD = 7
+NCC_EXT = 16
+NCCS = (NCC+NCC_PAD+NCC_EXT)
+VINTR = 0
+VQUIT = 1
+VERASE = 2
+VKILL = 3
+VEOF = 4
+VEOL = 5
+VEOL2 = 6
+VMIN = VEOF
+VTIME = VEOL
+VSWTCH = 7
+VLNEXT = (NCC+NCC_PAD+0)
+VWERASE = (NCC+NCC_PAD+1)
+VRPRNT = (NCC+NCC_PAD+2)
+VFLUSHO = (NCC+NCC_PAD+3)
+VSTOP = (NCC+NCC_PAD+4)
+VSTART = (NCC+NCC_PAD+5)
+CNUL = '\0'
+CDEL = '\377'
+CESC = '\\'
+CINTR = '\177'
+CQUIT = '\34'
+CBRK = '\377'
+def CTRL(c): return ord(c) & 0x0f
+CERASE = CTRL('H')
+CKILL = CTRL('U')
+CEOF = CTRL('d')
+CEOT = CEOF
+CSTART = CTRL('q')
+CSTOP = CTRL('s')
+CSWTCH = CTRL('z')
+CSUSP = CSWTCH
+CNSWTCH = 0
+CLNEXT = CTRL('v')
+CWERASE = CTRL('w')
+CFLUSHO = CTRL('o')
+CFLUSH = CFLUSHO
+CRPRNT = CTRL('r')
+CDSUSP = CTRL('y')
+IGNBRK = 0000001
+BRKINT = 0000002
+IGNPAR = 0000004
+PARMRK = 0000010
+INPCK = 0000020
+ISTRIP = 0000040
+INLCR = 0000100
+IGNCR = 0000200
+ICRNL = 0000400
+IUCLC = 0001000
+IXON = 0002000
+IXANY = 0004000
+IXOFF = 0010000
+IBLKMD = 0020000
+OPOST = 0000001
+OLCUC = 0000002
+ONLCR = 0000004
+OCRNL = 0000010
+ONOCR = 0000020
+ONLRET = 0000040
+OFILL = 0000100
+OFDEL = 0000200
+NLDLY = 0000400
+NL0 = 0
+NL1 = 0000400
+CRDLY = 0003000
+CR0 = 0
+CR1 = 0001000
+CR2 = 0002000
+CR3 = 0003000
+TABDLY = 0014000
+TAB0 = 0
+TAB1 = 0004000
+TAB2 = 0010000
+TAB3 = 0014000
+BSDLY = 0020000
+BS0 = 0
+BS1 = 0020000
+VTDLY = 0040000
+VT0 = 0
+VT1 = 0040000
+FFDLY = 0100000
+FF0 = 0
+FF1 = 0100000
+CBAUD = 0000017
+B0 = 0
+B50 = 0000001
+B75 = 0000002
+B110 = 0000003
+B134 = 0000004
+B150 = 0000005
+B200 = 0000006
+B300 = 0000007
+B600 = 0000010
+B1200 = 0000011
+B1800 = 0000012
+B2400 = 0000013
+B4800 = 0000014
+B9600 = 0000015
+B19200 = 0000016
+EXTA = 0000016
+B38400 = 0000017
+EXTB = 0000017
+CSIZE = 0000060
+CS5 = 0
+CS6 = 0000020
+CS7 = 0000040
+CS8 = 0000060
+CSTOPB = 0000100
+CREAD = 0000200
+PARENB = 0000400
+PARODD = 0001000
+HUPCL = 0002000
+CLOCAL = 0004000
+LOBLK = 0040000
+ISIG = 0000001
+ICANON = 0000002
+XCASE = 0000004
+ECHO = 0000010
+ECHOE = 0000020
+ECHOK = 0000040
+ECHONL = 0000100
+NOFLSH = 0000200
+IIEXTEN = 0000400
+ITOSTOP = 0001000
+SSPEED = B9600
+IOCTYPE = 0xff00
+TIOC = (ord('T')<<8)
+oTCGETA = (TIOC|1)
+oTCSETA = (TIOC|2)
+oTCSETAW = (TIOC|3)
+oTCSETAF = (TIOC|4)
+TCSBRK = (TIOC|5)
+TCXONC = (TIOC|6)
+TCFLSH = (TIOC|7)
+TCGETA = (TIOC|8)
+TCSETA = (TIOC|9)
+TCSETAW = (TIOC|10)
+TCSETAF = (TIOC|11)
+TIOCFLUSH = (TIOC|12)
+TCDSET = (TIOC|32)
+TCBLKMD = (TIOC|33)
+TIOCPKT = (TIOC|112)
+TIOCPKT_DATA = 0x00
+TIOCPKT_FLUSHREAD = 0x01
+TIOCPKT_FLUSHWRITE = 0x02
+TIOCPKT_NOSTOP = 0x10
+TIOCPKT_DOSTOP = 0x20
+TIOCNOTTY = (TIOC|113)
+TIOCSTI = (TIOC|114)
+TIOCSPGRP = _IOW(ord('t'), 118, int)
+TIOCGPGRP = _IOR(ord('t'), 119, int)
+TIOCCONS = _IOW(ord('t'), 120, int)
+struct_winsize = 'hhhh'
+TIOCGWINSZ = _IOR(ord('t'), 104, struct_winsize)
+TIOCSWINSZ = _IOW(ord('t'), 103, struct_winsize)
+TFIOC = (ord('F')<<8)
+oFIONREAD = (TFIOC|127)
+LDIOC = (ord('D')<<8)
+LDOPEN = (LDIOC|0)
+LDCLOSE = (LDIOC|1)
+LDCHG = (LDIOC|2)
+LDGETT = (LDIOC|8)
+LDSETT = (LDIOC|9)
+TERM_NONE = 0
+TERM_TEC = 1
+TERM_V61 = 2
+TERM_V10 = 3
+TERM_TEX = 4
+TERM_D40 = 5
+TERM_H45 = 6
+TERM_D42 = 7
+TM_NONE = 0000
+TM_SNL = 0001
+TM_ANL = 0002
+TM_LCF = 0004
+TM_CECHO = 0010
+TM_CINVIS = 0020
+TM_SET = 0200
+LDISC0 = 0
+LDISC1 = 1
+NTTYDISC = LDISC1
+VSUSP = VSWTCH
+TCSANOW = 0
+TCSADRAIN = 1
+TCSAFLUSH = 2
+TCIFLUSH = 0
+TCOFLUSH = 1
+TCIOFLUSH = 2
+TCOOFF = 0
+TCOON = 1
+TCIOFF = 2
+TCION = 3
+TO_STOP = LOBLK
+IEXTEN = IIEXTEN
+TOSTOP = ITOSTOP
diff --git a/Lib/irix5/SOCKET.py b/Lib/irix5/SOCKET.py
new file mode 100755
index 0000000..8a15ef9
--- /dev/null
+++ b/Lib/irix5/SOCKET.py
@@ -0,0 +1,77 @@
+SOCK_STREAM = 1
+SOCK_DGRAM = 2
+SOCK_RAW = 3
+SOCK_RDM = 4
+SOCK_SEQPACKET = 5
+SO_DEBUG = 0x0001
+SO_ACCEPTCONN = 0x0002
+SO_REUSEADDR = 0x0004
+SO_KEEPALIVE = 0x0008
+SO_DONTROUTE = 0x0010
+SO_BROADCAST = 0x0020
+SO_USELOOPBACK = 0x0040
+SO_LINGER = 0x0080
+SO_OOBINLINE = 0x0100
+SO_REUSEPORT = 0x0200
+SO_SNDBUF = 0x1001
+SO_RCVBUF = 0x1002
+SO_SNDLOWAT = 0x1003
+SO_RCVLOWAT = 0x1004
+SO_SNDTIMEO = 0x1005
+SO_RCVTIMEO = 0x1006
+SO_ERROR = 0x1007
+SO_TYPE = 0x1008
+SOL_SOCKET = 0xffff
+AF_UNSPEC = 0
+AF_UNIX = 1
+AF_INET = 2
+AF_IMPLINK = 3
+AF_PUP = 4
+AF_CHAOS = 5
+AF_NS = 6
+AF_ISO = 7
+AF_OSI = AF_ISO
+AF_ECMA = 8
+AF_DATAKIT = 9
+AF_CCITT = 10
+AF_SNA = 11
+AF_DECnet = 12
+AF_DLI = 13
+AF_LAT = 14
+AF_HYLINK = 15
+AF_APPLETALK = 16
+AF_ROUTE = 17
+AF_RAW = 18
+AF_LINK = 18
+pseudo_AF_XTP = 19
+AF_MAX = 20
+PF_UNSPEC = AF_UNSPEC
+PF_UNIX = AF_UNIX
+PF_INET = AF_INET
+PF_IMPLINK = AF_IMPLINK
+PF_PUP = AF_PUP
+PF_CHAOS = AF_CHAOS
+PF_NS = AF_NS
+PF_ISO = AF_ISO
+PF_OSI = AF_ISO
+PF_ECMA = AF_ECMA
+PF_DATAKIT = AF_DATAKIT
+PF_CCITT = AF_CCITT
+PF_SNA = AF_SNA
+PF_DECnet = AF_DECnet
+PF_DLI = AF_DLI
+PF_LAT = AF_LAT
+PF_HYLINK = AF_HYLINK
+PF_APPLETALK = AF_APPLETALK
+PF_ROUTE = AF_ROUTE
+PF_LINK = AF_LINK
+PF_XTP = pseudo_AF_XTP
+PF_RAW = AF_RAW
+PF_MAX = AF_MAX
+SOMAXCONN = 5
+MSG_OOB = 0x1
+MSG_PEEK = 0x2
+MSG_DONTROUTE = 0x4
+MSG_BTAG = 0x40
+MSG_ETAG = 0x80
+MSG_MAXIOVLEN = 16
diff --git a/Lib/irix5/jpeg.py b/Lib/irix5/jpeg.py
new file mode 100755
index 0000000..85d6d83
--- /dev/null
+++ b/Lib/irix5/jpeg.py
@@ -0,0 +1,110 @@
+# Implement 'jpeg' interface using SGI's compression library
+
+# XXX Options 'smooth' and 'optimize' are ignored.
+
+# XXX It appears that compressing grayscale images doesn't work right;
+# XXX the resulting file causes weirdness.
+
+error = 'jpeg.error' # Exception
+
+options = {'quality': 75, 'optimize': 0, 'smooth': 0, 'forcegray': 0}
+
+comp = None
+decomp = None
+
+def compress(imgdata, width, height, bytesperpixel):
+ global comp
+ import cl, CL
+ if comp is None: comp = cl.OpenCompressor(CL.JPEG)
+ if bytesperpixel == 1:
+ format = CL.GRAYSCALE
+ elif bytesperpixel == 4:
+ format = CL.RGBX
+ if options['forcegray']:
+ iformat = CL.GRAYSCALE
+ else:
+ iformat = CL.YUV
+ # XXX How to support 'optimize'?
+ params = [CL.IMAGE_WIDTH, width, CL.IMAGE_HEIGHT, height, \
+ CL.ORIGINAL_FORMAT, format, \
+ CL.ORIENTATION, CL.BOTTOM_UP, \
+ CL.QUALITY_FACTOR, options['quality'], \
+ CL.INTERNAL_FORMAT, iformat, \
+ ]
+ comp.SetParams(params)
+ jpegdata = comp.Compress(1, imgdata)
+ return jpegdata
+
+def decompress(jpegdata):
+ global decomp
+ import cl, CL
+ if decomp is None: decomp = cl.OpenDecompressor(CL.JPEG)
+ headersize = decomp.ReadHeader(jpegdata)
+ params = [CL.IMAGE_WIDTH, 0, CL.IMAGE_HEIGHT, 0, CL.INTERNAL_FORMAT, 0]
+ decomp.GetParams(params)
+ width, height, format = params[1], params[3], params[5]
+ if format == CL.GRAYSCALE or options['forcegray']:
+ format = CL.GRAYSCALE
+ bytesperpixel = 1
+ else:
+ format = CL.RGBX
+ bytesperpixel = 4
+ # XXX How to support 'smooth'?
+ params = [CL.ORIGINAL_FORMAT, format, \
+ CL.ORIENTATION, CL.BOTTOM_UP, \
+ CL.FRAME_BUFFER_SIZE, width*height*bytesperpixel]
+ decomp.SetParams(params)
+ imgdata = decomp.Decompress(1, jpegdata)
+ return imgdata, width, height, bytesperpixel
+
+def setoption(name, value):
+ if type(value) <> type(0):
+ raise TypeError, 'jpeg.setoption: numeric options only'
+ if name == 'forcegrey':
+ name = 'forcegray'
+ if not options.has_key(name):
+ raise KeyError, 'jpeg.setoption: unknown option name'
+ options[name] = int(value)
+
+def test():
+ import sys
+ if sys.argv[1:2] == ['-g']:
+ del sys.argv[1]
+ setoption('forcegray', 1)
+ if not sys.argv[1:]:
+ sys.argv.append('/usr/local/images/data/jpg/asterix.jpg')
+ for file in sys.argv[1:]:
+ show(file)
+
+def show(file):
+ import gl, GL, DEVICE
+ jpegdata = open(file, 'r').read()
+ imgdata, width, height, bytesperpixel = decompress(jpegdata)
+ gl.foreground()
+ gl.prefsize(width, height)
+ win = gl.winopen(file)
+ if bytesperpixel == 1:
+ gl.cmode()
+ gl.pixmode(GL.PM_SIZE, 8)
+ gl.gconfig()
+ for i in range(256):
+ gl.mapcolor(i, i, i, i)
+ else:
+ gl.RGBmode()
+ gl.pixmode(GL.PM_SIZE, 32)
+ gl.gconfig()
+ gl.qdevice(DEVICE.REDRAW)
+ gl.qdevice(DEVICE.ESCKEY)
+ gl.qdevice(DEVICE.WINQUIT)
+ gl.qdevice(DEVICE.WINSHUT)
+ gl.lrectwrite(0, 0, width-1, height-1, imgdata)
+ while 1:
+ dev, val = gl.qread()
+ if dev in (DEVICE.ESCKEY, DEVICE.WINSHUT, DEVICE.WINQUIT):
+ break
+ if dev == DEVICE.REDRAW:
+ gl.lrectwrite(0, 0, width-1, height-1, imgdata)
+ gl.winclose(win)
+ # Now test the compression and write the result to a fixed filename
+ newjpegdata = compress(imgdata, width, height, bytesperpixel)
+ open('/tmp/j.jpg', 'w').write(newjpegdata)