summaryrefslogtreecommitdiff
path: root/sys/lib/python/plat-irix5
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@localhost>2011-05-03 11:25:13 +0000
committercinap_lenrek <cinap_lenrek@localhost>2011-05-03 11:25:13 +0000
commit458120dd40db6b4df55a4e96b650e16798ef06a0 (patch)
tree8f82685be24fef97e715c6f5ca4c68d34d5074ee /sys/lib/python/plat-irix5
parent3a742c699f6806c1145aea5149bf15de15a0afd7 (diff)
add hg and python
Diffstat (limited to 'sys/lib/python/plat-irix5')
-rwxr-xr-xsys/lib/python/plat-irix5/AL.py61
-rwxr-xr-xsys/lib/python/plat-irix5/CD.py34
-rwxr-xr-xsys/lib/python/plat-irix5/CL.py24
-rwxr-xr-xsys/lib/python/plat-irix5/CL_old.py236
-rwxr-xr-xsys/lib/python/plat-irix5/DEVICE.py400
-rwxr-xr-xsys/lib/python/plat-irix5/ERRNO.py147
-rwxr-xr-xsys/lib/python/plat-irix5/FILE.py239
-rwxr-xr-xsys/lib/python/plat-irix5/FL.py289
-rwxr-xr-xsys/lib/python/plat-irix5/GET.py59
-rwxr-xr-xsys/lib/python/plat-irix5/GL.py393
-rwxr-xr-xsys/lib/python/plat-irix5/GLWS.py12
-rwxr-xr-xsys/lib/python/plat-irix5/IN.py141
-rwxr-xr-xsys/lib/python/plat-irix5/IOCTL.py233
-rwxr-xr-xsys/lib/python/plat-irix5/SV.py120
-rwxr-xr-xsys/lib/python/plat-irix5/WAIT.py14
-rwxr-xr-xsys/lib/python/plat-irix5/cddb.py204
-rwxr-xr-xsys/lib/python/plat-irix5/cdplayer.py88
-rwxr-xr-xsys/lib/python/plat-irix5/flp.doc117
-rwxr-xr-xsys/lib/python/plat-irix5/flp.py451
-rwxr-xr-xsys/lib/python/plat-irix5/jpeg.py111
-rwxr-xr-xsys/lib/python/plat-irix5/panel.py281
-rwxr-xr-xsys/lib/python/plat-irix5/panelparser.py128
-rwxr-xr-xsys/lib/python/plat-irix5/readcd.doc104
-rwxr-xr-xsys/lib/python/plat-irix5/readcd.py244
-rwxr-xr-xsys/lib/python/plat-irix5/regen10
-rwxr-xr-xsys/lib/python/plat-irix5/torgb.py99
26 files changed, 4239 insertions, 0 deletions
diff --git a/sys/lib/python/plat-irix5/AL.py b/sys/lib/python/plat-irix5/AL.py
new file mode 100755
index 000000000..ec941a2ba
--- /dev/null
+++ b/sys/lib/python/plat-irix5/AL.py
@@ -0,0 +1,61 @@
+RATE_48000 = 48000
+RATE_44100 = 44100
+RATE_32000 = 32000
+RATE_22050 = 22050
+RATE_16000 = 16000
+RATE_11025 = 11025
+RATE_8000 = 8000
+
+SAMPFMT_TWOSCOMP= 1
+SAMPFMT_FLOAT = 32
+SAMPFMT_DOUBLE = 64
+
+SAMPLE_8 = 1
+SAMPLE_16 = 2
+ # SAMPLE_24 is the low 24 bits of a long, sign extended to 32 bits
+SAMPLE_24 = 4
+
+MONO = 1
+STEREO = 2
+QUADRO = 4 # 4CHANNEL is not a legal Python name
+
+INPUT_LINE = 0
+INPUT_MIC = 1
+INPUT_DIGITAL = 2
+
+MONITOR_OFF = 0
+MONITOR_ON = 1
+
+ERROR_NUMBER = 0
+ERROR_TYPE = 1
+ERROR_LOCATION_LSP = 2
+ERROR_LOCATION_MSP = 3
+ERROR_LENGTH = 4
+
+ERROR_INPUT_UNDERFLOW = 0
+ERROR_OUTPUT_OVERFLOW = 1
+
+# These seem to be not supported anymore:
+##HOLD, RELEASE = 0, 1
+##ATTAIL, ATHEAD, ATMARK, ATTIME = 0, 1, 2, 3
+
+DEFAULT_DEVICE = 1
+
+INPUT_SOURCE = 0
+LEFT_INPUT_ATTEN = 1
+RIGHT_INPUT_ATTEN = 2
+INPUT_RATE = 3
+OUTPUT_RATE = 4
+LEFT_SPEAKER_GAIN = 5
+RIGHT_SPEAKER_GAIN = 6
+INPUT_COUNT = 7
+OUTPUT_COUNT = 8
+UNUSED_COUNT = 9
+SYNC_INPUT_TO_AES = 10
+SYNC_OUTPUT_TO_AES = 11
+MONITOR_CTL = 12
+LEFT_MONITOR_ATTEN = 13
+RIGHT_MONITOR_ATTEN = 14
+
+ENUM_VALUE = 0 # only certain values are valid
+RANGE_VALUE = 1 # any value in range is valid
diff --git a/sys/lib/python/plat-irix5/CD.py b/sys/lib/python/plat-irix5/CD.py
new file mode 100755
index 000000000..8c1e03bc6
--- /dev/null
+++ b/sys/lib/python/plat-irix5/CD.py
@@ -0,0 +1,34 @@
+ERROR = 0
+NODISC = 1
+READY = 2
+PLAYING = 3
+PAUSED = 4
+STILL = 5
+
+AUDIO = 0
+PNUM = 1
+INDEX = 2
+PTIME = 3
+ATIME = 4
+CATALOG = 5
+IDENT = 6
+CONTROL = 7
+
+CDDA_DATASIZE = 2352
+
+##CDDA_SUBCODESIZE = (sizeof(struct subcodeQ))
+##CDDA_BLOCKSIZE = (sizeof(struct cdframe))
+##CDDA_NUMSAMPLES = (CDDA_DATASIZE/2)
+##
+##CDQ_PREEMP_MASK = 0xd
+##CDQ_COPY_MASK = 0xb
+##CDQ_DDATA_MASK = 0xd
+##CDQ_BROADCAST_MASK = 0x8
+##CDQ_PREEMPHASIS = 0x1
+##CDQ_COPY_PERMITTED = 0x2
+##CDQ_DIGITAL_DATA = 0x4
+##CDQ_BROADCAST_USE = 0x8
+##
+##CDQ_MODE1 = 0x1
+##CDQ_MODE2 = 0x2
+##CDQ_MODE3 = 0x3
diff --git a/sys/lib/python/plat-irix5/CL.py b/sys/lib/python/plat-irix5/CL.py
new file mode 100755
index 000000000..23259c554
--- /dev/null
+++ b/sys/lib/python/plat-irix5/CL.py
@@ -0,0 +1,24 @@
+# Backward compatible module CL.
+# All relevant symbols are now defined in the module cl.
+try:
+ from cl import *
+except ImportError:
+ from CL_old import *
+else:
+ del CompressImage
+ del DecompressImage
+ del GetAlgorithmName
+ del OpenCompressor
+ del OpenDecompressor
+ del QueryAlgorithms
+ del QueryMaxHeaderSize
+ del QueryScheme
+ del QuerySchemeFromName
+ del SetDefault
+ del SetMax
+ del SetMin
+ try:
+ del cvt_type
+ except NameError:
+ pass
+ del error
diff --git a/sys/lib/python/plat-irix5/CL_old.py b/sys/lib/python/plat-irix5/CL_old.py
new file mode 100755
index 000000000..967b49708
--- /dev/null
+++ b/sys/lib/python/plat-irix5/CL_old.py
@@ -0,0 +1,236 @@
+#
+# cl.h - Compression Library typedefs and prototypes
+#
+# 01/07/92 Cleanup by Brian Knittel
+# 02/18/92 Original Version by Brian Knittel
+#
+
+#
+# originalFormat parameter values
+#
+MAX_NUMBER_OF_ORIGINAL_FORMATS = 32
+
+# Audio
+MONO = 0
+STEREO_INTERLEAVED = 1
+
+# Video
+# YUV is defined to be the same thing as YCrCb (luma and two chroma components).
+# 422 is appended to YUV (or YCrCb) if the chroma is sub-sampled by 2
+# horizontally, packed as U Y1 V Y2 (byte order).
+# 422HC is appended to YUV (or YCrCb) if the chroma is sub-sampled by 2
+# vertically in addition to horizontally, and is packed the same as
+# 422 except that U & V are not valid on the second line.
+#
+RGB = 0
+RGBX = 1
+RGBA = 2
+RGB332 = 3
+
+GRAYSCALE = 4
+Y = 4
+YUV = 5
+YCbCr = 5
+YUV422 = 6 # 4:2:2 sampling
+YCbCr422 = 6 # 4:2:2 sampling
+YUV422HC = 7 # 4:1:1 sampling
+YCbCr422HC = 7 # 4:1:1 sampling
+YUV422DC = 7 # 4:1:1 sampling
+YCbCr422DC = 7 # 4:1:1 sampling
+
+BEST_FIT = -1
+
+def BytesPerSample(s):
+ if s in (MONO, YUV):
+ return 2
+ elif s == STEREO_INTERLEAVED:
+ return 4
+ else:
+ return 0
+
+def BytesPerPixel(f):
+ if f in (RGB, YUV):
+ return 3
+ elif f in (RGBX, RGBA):
+ return 4
+ elif f in (RGB332, GRAYSCALE):
+ return 1
+ else:
+ return 2
+
+def AudioFormatName(f):
+ if f == MONO:
+ return 'MONO'
+ elif f == STEREO_INTERLEAVED:
+ return 'STEREO_INTERLEAVED'
+ else:
+ return 'Not a valid format'
+
+def VideoFormatName(f):
+ if f == RGB:
+ return 'RGB'
+ elif f == RGBX:
+ return 'RGBX'
+ elif f == RGBA:
+ return 'RGBA'
+ elif f == RGB332:
+ return 'RGB332'
+ elif f == GRAYSCALE:
+ return 'GRAYSCALE'
+ elif f == YUV:
+ return 'YUV'
+ elif f == YUV422:
+ return 'YUV422'
+ elif f == YUV422DC:
+ return 'YUV422DC'
+ else:
+ return 'Not a valid format'
+
+MAX_NUMBER_OF_AUDIO_ALGORITHMS = 32
+MAX_NUMBER_OF_VIDEO_ALGORITHMS = 32
+
+#
+# Algorithm types
+#
+AUDIO = 0
+VIDEO = 1
+
+def AlgorithmNumber(scheme):
+ return scheme & 0x7fff
+def AlgorithmType(scheme):
+ return (scheme >> 15) & 1
+def Algorithm(type, n):
+ return n | ((type & 1) << 15)
+
+#
+# "compressionScheme" argument values
+#
+UNKNOWN_SCHEME = -1
+
+UNCOMPRESSED_AUDIO = Algorithm(AUDIO, 0)
+G711_ULAW = Algorithm(AUDIO, 1)
+ULAW = Algorithm(AUDIO, 1)
+G711_ALAW = Algorithm(AUDIO, 2)
+ALAW = Algorithm(AUDIO, 2)
+AWARE_MPEG_AUDIO = Algorithm(AUDIO, 3)
+AWARE_MULTIRATE = Algorithm(AUDIO, 4)
+
+UNCOMPRESSED = Algorithm(VIDEO, 0)
+UNCOMPRESSED_VIDEO = Algorithm(VIDEO, 0)
+RLE = Algorithm(VIDEO, 1)
+JPEG = Algorithm(VIDEO, 2)
+MPEG_VIDEO = Algorithm(VIDEO, 3)
+MVC1 = Algorithm(VIDEO, 4)
+RTR = Algorithm(VIDEO, 5)
+RTR1 = Algorithm(VIDEO, 5)
+
+#
+# Parameters
+#
+MAX_NUMBER_OF_PARAMS = 256
+# Default Parameters
+IMAGE_WIDTH = 0
+IMAGE_HEIGHT = 1
+ORIGINAL_FORMAT = 2
+INTERNAL_FORMAT = 3
+COMPONENTS = 4
+BITS_PER_COMPONENT = 5
+FRAME_RATE = 6
+COMPRESSION_RATIO = 7
+EXACT_COMPRESSION_RATIO = 8
+FRAME_BUFFER_SIZE = 9
+COMPRESSED_BUFFER_SIZE = 10
+BLOCK_SIZE = 11
+PREROLL = 12
+FRAME_TYPE = 13
+ALGORITHM_ID = 14
+ALGORITHM_VERSION = 15
+ORIENTATION = 16
+NUMBER_OF_FRAMES = 17
+SPEED = 18
+LAST_FRAME_INDEX = 19
+NUMBER_OF_PARAMS = 20
+
+# JPEG Specific Parameters
+QUALITY_FACTOR = NUMBER_OF_PARAMS + 0
+
+# MPEG Specific Parameters
+END_OF_SEQUENCE = NUMBER_OF_PARAMS + 0
+
+# RTR Specific Parameters
+QUALITY_LEVEL = NUMBER_OF_PARAMS + 0
+ZOOM_X = NUMBER_OF_PARAMS + 1
+ZOOM_Y = NUMBER_OF_PARAMS + 2
+
+#
+# Parameter value types
+#
+ENUM_VALUE = 0 # only certain constant values are valid
+RANGE_VALUE = 1 # any value in a given range is valid
+FLOATING_ENUM_VALUE = 2 # only certain constant floating point values are valid
+FLOATING_RANGE_VALUE = 3 # any value in a given floating point range is valid
+
+#
+# Algorithm Functionality
+#
+DECOMPRESSOR = 1
+COMPRESSOR = 2
+CODEC = 3
+
+#
+# Buffer types
+#
+NONE = 0
+FRAME = 1
+DATA = 2
+
+#
+# Frame types
+#
+NONE = 0
+KEYFRAME = 1
+INTRA = 1
+PREDICTED = 2
+BIDIRECTIONAL = 3
+
+#
+# Orientations
+#
+TOP_DOWN = 0
+BOTTOM_UP = 1
+
+#
+# SGI Proprietary Algorithm Header Start Code
+#
+HEADER_START_CODE = 0xc1C0DEC
+
+#
+# error codes
+#
+
+BAD_NO_BUFFERSPACE = -2 # no space for internal buffers
+BAD_PVBUFFER = -3 # param/val buffer doesn't make sense
+BAD_BUFFERLENGTH_NEG = -4 # negative buffer length
+BAD_BUFFERLENGTH_ODD = -5 # odd length parameter/value buffer
+BAD_PARAM = -6 # invalid parameter
+BAD_COMPRESSION_SCHEME = -7 # compression scheme parameter invalid
+BAD_COMPRESSOR_HANDLE = -8 # compression handle parameter invalid
+BAD_COMPRESSOR_HANDLE_POINTER = -9 # compression handle pointer invalid
+BAD_BUFFER_HANDLE = -10 # buffer handle invalid
+BAD_BUFFER_QUERY_SIZE = -11 # buffer query size too large
+JPEG_ERROR = -12 # error from libjpeg
+BAD_FRAME_SIZE = -13 # frame size invalid
+PARAM_OUT_OF_RANGE = -14 # parameter out of range
+ADDED_ALGORITHM_ERROR = -15 # added algorithm had a unique error
+BAD_ALGORITHM_TYPE = -16 # bad algorithm type
+BAD_ALGORITHM_NAME = -17 # bad algorithm name
+BAD_BUFFERING = -18 # bad buffering calls
+BUFFER_NOT_CREATED = -19 # buffer not created
+BAD_BUFFER_EXISTS = -20 # buffer already created
+BAD_INTERNAL_FORMAT = -21 # invalid internal format
+BAD_BUFFER_POINTER = -22 # invalid buffer pointer
+FRAME_BUFFER_SIZE_ZERO = -23 # frame buffer has zero size
+BAD_STREAM_HEADER = -24 # invalid stream header
+
+BAD_LICENSE = -25 # netls license not valid
+AWARE_ERROR = -26 # error from libawcmp
diff --git a/sys/lib/python/plat-irix5/DEVICE.py b/sys/lib/python/plat-irix5/DEVICE.py
new file mode 100755
index 000000000..7ace8cb0b
--- /dev/null
+++ b/sys/lib/python/plat-irix5/DEVICE.py
@@ -0,0 +1,400 @@
+NULLDEV = 0
+BUTOFFSET = 1
+VALOFFSET = 256
+PSEUDOFFSET = 512
+BUT2OFFSET = 3840
+TIMOFFSET = 515
+XKBDOFFSET = 143
+BUTCOUNT = 255
+VALCOUNT = 256
+TIMCOUNT = 4
+XKBDCOUNT = 28
+USERBUTOFFSET = 4096
+USERVALOFFSET = 12288
+USERPSEUDOFFSET = 16384
+BUT0 = 1
+BUT1 = 2
+BUT2 = 3
+BUT3 = 4
+BUT4 = 5
+BUT5 = 6
+BUT6 = 7
+BUT7 = 8
+BUT8 = 9
+BUT9 = 10
+BUT10 = 11
+BUT11 = 12
+BUT12 = 13
+BUT13 = 14
+BUT14 = 15
+BUT15 = 16
+BUT16 = 17
+BUT17 = 18
+BUT18 = 19
+BUT19 = 20
+BUT20 = 21
+BUT21 = 22
+BUT22 = 23
+BUT23 = 24
+BUT24 = 25
+BUT25 = 26
+BUT26 = 27
+BUT27 = 28
+BUT28 = 29
+BUT29 = 30
+BUT30 = 31
+BUT31 = 32
+BUT32 = 33
+BUT33 = 34
+BUT34 = 35
+BUT35 = 36
+BUT36 = 37
+BUT37 = 38
+BUT38 = 39
+BUT39 = 40
+BUT40 = 41
+BUT41 = 42
+BUT42 = 43
+BUT43 = 44
+BUT44 = 45
+BUT45 = 46
+BUT46 = 47
+BUT47 = 48
+BUT48 = 49
+BUT49 = 50
+BUT50 = 51
+BUT51 = 52
+BUT52 = 53
+BUT53 = 54
+BUT54 = 55
+BUT55 = 56
+BUT56 = 57
+BUT57 = 58
+BUT58 = 59
+BUT59 = 60
+BUT60 = 61
+BUT61 = 62
+BUT62 = 63
+BUT63 = 64
+BUT64 = 65
+BUT65 = 66
+BUT66 = 67
+BUT67 = 68
+BUT68 = 69
+BUT69 = 70
+BUT70 = 71
+BUT71 = 72
+BUT72 = 73
+BUT73 = 74
+BUT74 = 75
+BUT75 = 76
+BUT76 = 77
+BUT77 = 78
+BUT78 = 79
+BUT79 = 80
+BUT80 = 81
+BUT81 = 82
+BUT82 = 83
+MAXKBDBUT = 83
+BUT100 = 101
+BUT101 = 102
+BUT102 = 103
+BUT103 = 104
+BUT104 = 105
+BUT105 = 106
+BUT106 = 107
+BUT107 = 108
+BUT108 = 109
+BUT109 = 110
+BUT110 = 111
+BUT111 = 112
+BUT112 = 113
+BUT113 = 114
+BUT114 = 115
+BUT115 = 116
+BUT116 = 117
+BUT117 = 118
+BUT118 = 119
+BUT119 = 120
+BUT120 = 121
+BUT121 = 122
+BUT122 = 123
+BUT123 = 124
+BUT124 = 125
+BUT125 = 126
+BUT126 = 127
+BUT127 = 128
+BUT128 = 129
+BUT129 = 130
+BUT130 = 131
+BUT131 = 132
+BUT132 = 133
+BUT133 = 134
+BUT134 = 135
+BUT135 = 136
+BUT136 = 137
+BUT137 = 138
+BUT138 = 139
+BUT139 = 140
+BUT140 = 141
+BUT141 = 142
+BUT142 = 143
+BUT143 = 144
+BUT144 = 145
+BUT145 = 146
+BUT146 = 147
+BUT147 = 148
+BUT148 = 149
+BUT149 = 150
+BUT150 = 151
+BUT151 = 152
+BUT152 = 153
+BUT153 = 154
+BUT154 = 155
+BUT155 = 156
+BUT156 = 157
+BUT157 = 158
+BUT158 = 159
+BUT159 = 160
+BUT160 = 161
+BUT161 = 162
+BUT162 = 163
+BUT163 = 164
+BUT164 = 165
+BUT165 = 166
+BUT166 = 167
+BUT167 = 168
+BUT168 = 169
+BUT181 = 182
+BUT182 = 183
+BUT183 = 184
+BUT184 = 185
+BUT185 = 186
+BUT186 = 187
+BUT187 = 188
+BUT188 = 189
+BUT189 = 190
+MOUSE1 = 101
+MOUSE2 = 102
+MOUSE3 = 103
+LEFTMOUSE = 103
+MIDDLEMOUSE = 102
+RIGHTMOUSE = 101
+LPENBUT = 104
+BPAD0 = 105
+BPAD1 = 106
+BPAD2 = 107
+BPAD3 = 108
+LPENVALID = 109
+SWBASE = 111
+SW0 = 111
+SW1 = 112
+SW2 = 113
+SW3 = 114
+SW4 = 115
+SW5 = 116
+SW6 = 117
+SW7 = 118
+SW8 = 119
+SW9 = 120
+SW10 = 121
+SW11 = 122
+SW12 = 123
+SW13 = 124
+SW14 = 125
+SW15 = 126
+SW16 = 127
+SW17 = 128
+SW18 = 129
+SW19 = 130
+SW20 = 131
+SW21 = 132
+SW22 = 133
+SW23 = 134
+SW24 = 135
+SW25 = 136
+SW26 = 137
+SW27 = 138
+SW28 = 139
+SW29 = 140
+SW30 = 141
+SW31 = 142
+SBBASE = 182
+SBPICK = 182
+SBBUT1 = 183
+SBBUT2 = 184
+SBBUT3 = 185
+SBBUT4 = 186
+SBBUT5 = 187
+SBBUT6 = 188
+SBBUT7 = 189
+SBBUT8 = 190
+AKEY = 11
+BKEY = 36
+CKEY = 28
+DKEY = 18
+EKEY = 17
+FKEY = 19
+GKEY = 26
+HKEY = 27
+IKEY = 40
+JKEY = 34
+KKEY = 35
+LKEY = 42
+MKEY = 44
+NKEY = 37
+OKEY = 41
+PKEY = 48
+QKEY = 10
+RKEY = 24
+SKEY = 12
+TKEY = 25
+UKEY = 33
+VKEY = 29
+WKEY = 16
+XKEY = 21
+YKEY = 32
+ZKEY = 20
+ZEROKEY = 46
+ONEKEY = 8
+TWOKEY = 14
+THREEKEY = 15
+FOURKEY = 22
+FIVEKEY = 23
+SIXKEY = 30
+SEVENKEY = 31
+EIGHTKEY = 38
+NINEKEY = 39
+BREAKKEY = 1
+SETUPKEY = 2
+CTRLKEY = 3
+LEFTCTRLKEY = CTRLKEY
+CAPSLOCKKEY = 4
+RIGHTSHIFTKEY = 5
+LEFTSHIFTKEY = 6
+NOSCRLKEY = 13
+ESCKEY = 7
+TABKEY = 9
+RETKEY = 51
+SPACEKEY = 83
+LINEFEEDKEY = 60
+BACKSPACEKEY = 61
+DELKEY = 62
+SEMICOLONKEY = 43
+PERIODKEY = 52
+COMMAKEY = 45
+QUOTEKEY = 50
+ACCENTGRAVEKEY = 55
+MINUSKEY = 47
+VIRGULEKEY = 53
+BACKSLASHKEY = 57
+EQUALKEY = 54
+LEFTBRACKETKEY = 49
+RIGHTBRACKETKEY = 56
+LEFTARROWKEY = 73
+DOWNARROWKEY = 74
+RIGHTARROWKEY = 80
+UPARROWKEY = 81
+PAD0 = 59
+PAD1 = 58
+PAD2 = 64
+PAD3 = 65
+PAD4 = 63
+PAD5 = 69
+PAD6 = 70
+PAD7 = 67
+PAD8 = 68
+PAD9 = 75
+PADPF1 = 72
+PADPF2 = 71
+PADPF3 = 79
+PADPF4 = 78
+PADPERIOD = 66
+PADMINUS = 76
+PADCOMMA = 77
+PADENTER = 82
+LEFTALTKEY = 143
+RIGHTALTKEY = 144
+RIGHTCTRLKEY = 145
+F1KEY = 146
+F2KEY = 147
+F3KEY = 148
+F4KEY = 149
+F5KEY = 150
+F6KEY = 151
+F7KEY = 152
+F8KEY = 153
+F9KEY = 154
+F10KEY = 155
+F11KEY = 156
+F12KEY = 157
+PRINTSCREENKEY = 158
+SCROLLLOCKKEY = 159
+PAUSEKEY = 160
+INSERTKEY = 161
+HOMEKEY = 162
+PAGEUPKEY = 163
+ENDKEY = 164
+PAGEDOWNKEY = 165
+NUMLOCKKEY = 166
+PADVIRGULEKEY = 167
+PADASTERKEY = 168
+PADPLUSKEY = 169
+SGIRESERVED = 256
+DIAL0 = 257
+DIAL1 = 258
+DIAL2 = 259
+DIAL3 = 260
+DIAL4 = 261
+DIAL5 = 262
+DIAL6 = 263
+DIAL7 = 264
+DIAL8 = 265
+MOUSEX = 266
+MOUSEY = 267
+LPENX = 268
+LPENY = 269
+BPADX = 270
+BPADY = 271
+CURSORX = 272
+CURSORY = 273
+GHOSTX = 274
+GHOSTY = 275
+SBTX = 276
+SBTY = 277
+SBTZ = 278
+SBRX = 279
+SBRY = 280
+SBRZ = 281
+SBPERIOD = 282
+TIMER0 = 515
+TIMER1 = 516
+TIMER2 = 517
+TIMER3 = 518
+KEYBD = 513
+RAWKEYBD = 514
+VALMARK = 523
+REDRAW = 528
+INPUTCHANGE = 534
+QFULL = 535
+QREADERROR = 538
+WINFREEZE = 539
+WINTHAW = 540
+REDRAWICONIC = 541
+WINQUIT = 542
+DEPTHCHANGE = 543
+WINSHUT = 546
+DRAWOVERLAY = 547
+VIDEO = 548
+MENUBUTTON = RIGHTMOUSE
+WINCLOSE = 537
+KEYBDFNAMES = 544
+KEYBDFSTRINGS = 545
+MAXSGIDEVICE = 20000
+GERROR = 524
+WMSEND = 529
+WMREPLY = 530
+WMGFCLOSE = 531
+WMTXCLOSE = 532
+MODECHANGE = 533
+PIECECHANGE = 536
diff --git a/sys/lib/python/plat-irix5/ERRNO.py b/sys/lib/python/plat-irix5/ERRNO.py
new file mode 100755
index 000000000..d49e9641e
--- /dev/null
+++ b/sys/lib/python/plat-irix5/ERRNO.py
@@ -0,0 +1,147 @@
+# Generated by h2py from /usr/include/errno.h
+
+# Included from sys/errno.h
+__KBASE = 1000
+__IRIXBASE = 1000
+EPERM = 1
+ENOENT = 2
+ESRCH = 3
+EINTR = 4
+EIO = 5
+ENXIO = 6
+E2BIG = 7
+ENOEXEC = 8
+EBADF = 9
+ECHILD = 10
+EAGAIN = 11
+ENOMEM = 12
+EACCES = 13
+EFAULT = 14
+ENOTBLK = 15
+EBUSY = 16
+EEXIST = 17
+EXDEV = 18
+ENODEV = 19
+ENOTDIR = 20
+EISDIR = 21
+EINVAL = 22
+ENFILE = 23
+EMFILE = 24
+ENOTTY = 25
+ETXTBSY = 26
+EFBIG = 27
+ENOSPC = 28
+ESPIPE = 29
+EROFS = 30
+EMLINK = 31
+EPIPE = 32
+EDOM = 33
+ERANGE = 34
+ENOMSG = 35
+EIDRM = 36
+ECHRNG = 37
+EL2NSYNC = 38
+EL3HLT = 39
+EL3RST = 40
+ELNRNG = 41
+EUNATCH = 42
+ENOCSI = 43
+EL2HLT = 44
+EDEADLK = 45
+ENOLCK = 46
+EBADE = 50
+EBADR = 51
+EXFULL = 52
+ENOANO = 53
+EBADRQC = 54
+EBADSLT = 55
+EDEADLOCK = 56
+EBFONT = 57
+ENOSTR = 60
+ENODATA = 61
+ETIME = 62
+ENOSR = 63
+ENONET = 64
+ENOPKG = 65
+EREMOTE = 66
+ENOLINK = 67
+EADV = 68
+ESRMNT = 69
+ECOMM = 70
+EPROTO = 71
+EMULTIHOP = 74
+EBADMSG = 77
+ENAMETOOLONG = 78
+EOVERFLOW = 79
+ENOTUNIQ = 80
+EBADFD = 81
+EREMCHG = 82
+ELIBACC = 83
+ELIBBAD = 84
+ELIBSCN = 85
+ELIBMAX = 86
+ELIBEXEC = 87
+EILSEQ = 88
+ENOSYS = 89
+ELOOP = 90
+ERESTART = 91
+ESTRPIPE = 92
+ENOTEMPTY = 93
+EUSERS = 94
+ENOTSOCK = 95
+EDESTADDRREQ = 96
+EMSGSIZE = 97
+EPROTOTYPE = 98
+ENOPROTOOPT = 99
+EPROTONOSUPPORT = 120
+ESOCKTNOSUPPORT = 121
+EOPNOTSUPP = 122
+EPFNOSUPPORT = 123
+EAFNOSUPPORT = 124
+EADDRINUSE = 125
+EADDRNOTAVAIL = 126
+ENETDOWN = 127
+ENETUNREACH = 128
+ENETRESET = 129
+ECONNABORTED = 130
+ECONNRESET = 131
+ENOBUFS = 132
+EISCONN = 133
+ENOTCONN = 134
+ESHUTDOWN = 143
+ETOOMANYREFS = 144
+ETIMEDOUT = 145
+ECONNREFUSED = 146
+EHOSTDOWN = 147
+EHOSTUNREACH = 148
+EWOULDBLOCK = __KBASE+101
+EWOULDBLOCK = EAGAIN
+EALREADY = 149
+EINPROGRESS = 150
+ESTALE = 151
+EIORESID = 500
+EUCLEAN = 135
+ENOTNAM = 137
+ENAVAIL = 138
+EISNAM = 139
+EREMOTEIO = 140
+EINIT = 141
+EREMDEV = 142
+ECANCELED = 158
+ECANCELED = 1000
+EDQUOT = 1133
+ENFSREMOTE = 1135
+ETCP_EBASE = 100
+ETCP_ELIMIT = 129
+ENAMI_EBASE = 129
+ENAMI_ELIMIT = 131
+ENFS_EBASE = 131
+ENFS_ELIMIT = 135
+ELASTERRNO = 135
+TCP_EBASE = ETCP_EBASE
+TCP_ELIMIT = ETCP_ELIMIT
+NAMI_EBASE = ENAMI_EBASE
+NAMI_ELIMIT = ENAMI_ELIMIT
+NFS_EBASE = ENFS_EBASE
+NFS_ELIMIT = ENFS_ELIMIT
+LASTERRNO = ELASTERRNO
diff --git a/sys/lib/python/plat-irix5/FILE.py b/sys/lib/python/plat-irix5/FILE.py
new file mode 100755
index 000000000..05697c15e
--- /dev/null
+++ b/sys/lib/python/plat-irix5/FILE.py
@@ -0,0 +1,239 @@
+# Generated by h2py from /usr/include/sys/file.h
+
+# Included from sys/types.h
+
+# Included from sgidefs.h
+_MIPS_ISA_MIPS1 = 1
+_MIPS_ISA_MIPS2 = 2
+_MIPS_ISA_MIPS3 = 3
+_MIPS_ISA_MIPS4 = 4
+_MIPS_SIM_ABI32 = 1
+_MIPS_SIM_NABI32 = 2
+_MIPS_SIM_ABI64 = 3
+P_MYID = (-1)
+P_MYHOSTID = (-1)
+
+# Included from sys/bsd_types.h
+
+# Included from sys/mkdev.h
+ONBITSMAJOR = 7
+ONBITSMINOR = 8
+OMAXMAJ = 0x7f
+OMAXMIN = 0xff
+NBITSMAJOR = 14
+NBITSMINOR = 18
+MAXMAJ = 0x1ff
+MAXMIN = 0x3ffff
+OLDDEV = 0
+NEWDEV = 1
+MKDEV_VER = NEWDEV
+def major(dev): return __major(MKDEV_VER, dev)
+
+def minor(dev): return __minor(MKDEV_VER, dev)
+
+
+# Included from sys/select.h
+FD_SETSIZE = 1024
+NBBY = 8
+
+# Included from sys/sema.h
+HP_NOPOLICY = 0
+HP_ADDOFF = 1
+HP_MULOFF = 2
+SEMA_NAMSZ = 8
+SEMA_NOHIST = 0x1
+SEMA_LIFO = 0x2
+SEMA_MUTEX = 0x4
+SEMA_METER = 0x8
+SEMAOP_PSEMA = 1
+SEMAOP_VSEMA = 2
+SEMAOP_CPSEMA = 3
+SEMAOP_CVSEMA = 4
+SEMAOP_WSEMA = 5
+SEMAOP_UNSEMA = 6
+SEMAOP_INIT = 7
+SEMAOP_FREE = 8
+SSOP_PHIT = 1
+SSOP_PSLP = 2
+SSOP_PWAKE = 6
+SSOP_PRESIG = 7
+SSOP_POSTSIG = 8
+SSOP_VNOWAKE = 3
+SSOP_VWAKE = 4
+SSOP_CPHIT = 1
+SSOP_CPMISS = 5
+SSOP_CVNOWAKE = 3
+SSOP_CVWAKE = 4
+SSOP_WMISS = 5
+SSOP_WWAKE = 4
+SSOP_RMV = 9
+TZERO = 10
+SEMA_NOP = 0
+SEMA_WAKE = 1
+SEMA_VSEMA = 2
+SEMA_SPINOP = 3
+MR_ACCESS = 0x1
+MR_UPDATE = 0x2
+def cv_signal(cv): return cvsema(cv);
+
+def cv_destroy(cv): return freesema(cv)
+
+def mutex_enter(m): return psema(m, PZERO | PNOSTOP)
+
+def mutex_exit(m): return vsema(m)
+
+def mutex_destroy(m): return freesema(m)
+
+def MUTEX_HELD(m): return (ownsema(m))
+
+def MUTEX_HELD(m): return (1)
+
+RW_READER = MR_ACCESS
+RW_WRITER = MR_UPDATE
+def rw_exit(r): return mrunlock(r)
+
+def rw_tryupgrade(r): return cmrpromote(r)
+
+def rw_downgrade(r): return mrdemote(r)
+
+def rw_destroy(r): return mrfree(r)
+
+def RW_WRITE_HELD(r): return ismrlocked(r, MR_UPDATE)
+
+def RW_READ_HELD(r): return ismrlocked(r, MR_ACCESS)
+
+
+# Included from sys/splock.h
+SPLOCKNAMSIZ = 8
+SPLOCK_NONE = 0
+SPLOCK_SOFT = 1
+SPLOCK_HARD = 2
+OWNER_NONE = -1
+MAP_LOCKID = 0
+SPLOCK_MAX = (96*1024)
+SPLOCK_MAX = 32768
+MIN_POOL_SIZE = 256
+MAX_POOL_SIZE = 16384
+DEF_SEMA_POOL = 8192
+DEF_VNODE_POOL = 1024
+DEF_FILE_POOL = 1024
+def ownlock(x): return 1
+
+def splock(x): return 1
+
+def io_splock(x): return 1
+
+def apvsema(x): return vsema(x)
+
+def apcpsema(x): return cpsema(x)
+
+def apcvsema(x): return cvsema(x)
+
+def mp_mrunlock(a): return mrunlock(a)
+
+def apvsema(x): return 0
+
+def apcpsema(x): return 1
+
+def apcvsema(x): return 0
+
+def mp_mrunlock(a): return 0
+
+
+# Included from sys/fcntl.h
+FNDELAY = 0x04
+FAPPEND = 0x08
+FSYNC = 0x10
+FNONBLOCK = 0x80
+FASYNC = 0x1000
+FNONBLK = FNONBLOCK
+FDIRECT = 0x8000
+FCREAT = 0x0100
+FTRUNC = 0x0200
+FEXCL = 0x0400
+FNOCTTY = 0x0800
+O_RDONLY = 0
+O_WRONLY = 1
+O_RDWR = 2
+O_NDELAY = 0x04
+O_APPEND = 0x08
+O_SYNC = 0x10
+O_NONBLOCK = 0x80
+O_DIRECT = 0x8000
+O_CREAT = 0x100
+O_TRUNC = 0x200
+O_EXCL = 0x400
+O_NOCTTY = 0x800
+F_DUPFD = 0
+F_GETFD = 1
+F_SETFD = 2
+F_GETFL = 3
+F_SETFL = 4
+F_GETLK = 14
+F_SETLK = 6
+F_SETLKW = 7
+F_CHKFL = 8
+F_ALLOCSP = 10
+F_FREESP = 11
+F_SETBSDLK = 12
+F_SETBSDLKW = 13
+F_DIOINFO = 30
+F_FSGETXATTR = 31
+F_FSSETXATTR = 32
+F_GETLK64 = 33
+F_SETLK64 = 34
+F_SETLKW64 = 35
+F_ALLOCSP64 = 36
+F_FREESP64 = 37
+F_GETBMAP = 38
+F_FSSETDM = 39
+F_RSETLK = 20
+F_RGETLK = 21
+F_RSETLKW = 22
+F_GETOWN = 23
+F_SETOWN = 24
+F_O_GETLK = 5
+F_O_GETOWN = 10
+F_O_SETOWN = 11
+F_RDLCK = 01
+F_WRLCK = 02
+F_UNLCK = 03
+O_ACCMODE = 3
+FD_CLOEXEC = 1
+FD_NODUP_FORK = 4
+FMASK = 0x90FF
+FOPEN = 0xFFFFFFFF
+FREAD = 0x01
+FWRITE = 0x02
+FNDELAY = 0x04
+FAPPEND = 0x08
+FSYNC = 0x10
+FNONBLOCK = 0x80
+FASYNC = 0x1000
+FNONBLK = FNONBLOCK
+FDIRECT = 0x8000
+FCREAT = 0x0100
+FTRUNC = 0x0200
+FEXCL = 0x0400
+FNOCTTY = 0x0800
+IRIX4_FASYNC = 0x40
+FMARK = 0x4000
+FDEFER = 0x2000
+FINPROGRESS = 0x0400
+FINVIS = 0x0100
+FNMFS = 0x2000
+FCLOSEXEC = 001
+FDSHD = 0x0001
+FDNOMARK = 0x0002
+FDIGNPROGRESS = 0x0004
+LOCK_SH = 1
+LOCK_EX = 2
+LOCK_NB = 4
+LOCK_UN = 8
+F_OK = 0
+X_OK = 1
+W_OK = 2
+R_OK = 4
+L_SET = 0
+L_INCR = 1
+L_XTND = 2
diff --git a/sys/lib/python/plat-irix5/FL.py b/sys/lib/python/plat-irix5/FL.py
new file mode 100755
index 000000000..727da4c9a
--- /dev/null
+++ b/sys/lib/python/plat-irix5/FL.py
@@ -0,0 +1,289 @@
+# Constants used by the FORMS library (module fl).
+# This corresponds to "forms.h".
+# Recommended use: import FL; ... FL.NORMAL_BOX ... etc.
+# Alternate use: from FL import *; ... NORMAL_BOX ... etc.
+
+_v20 = 1
+_v21 = 1
+##import fl
+##try:
+## _v20 = (fl.get_rgbmode is not None)
+##except:
+## _v20 = 0
+##del fl
+
+NULL = 0
+FALSE = 0
+TRUE = 1
+
+EVENT = -1
+
+LABEL_SIZE = 64
+if _v20:
+ SHORTCUT_SIZE = 32
+PLACE_FREE = 0
+PLACE_SIZE = 1
+PLACE_ASPECT = 2
+PLACE_MOUSE = 3
+PLACE_CENTER = 4
+PLACE_POSITION = 5
+FL_PLACE_FULLSCREEN = 6
+FIND_INPUT = 0
+FIND_AUTOMATIC = 1
+FIND_MOUSE = 2
+BEGIN_GROUP = 10000
+END_GROUP = 20000
+ALIGN_TOP = 0
+ALIGN_BOTTOM = 1
+ALIGN_LEFT = 2
+ALIGN_RIGHT = 3
+ALIGN_CENTER = 4
+NO_BOX = 0
+UP_BOX = 1
+DOWN_BOX = 2
+FLAT_BOX = 3
+BORDER_BOX = 4
+SHADOW_BOX = 5
+FRAME_BOX = 6
+ROUNDED_BOX = 7
+RFLAT_BOX = 8
+RSHADOW_BOX = 9
+TOP_BOUND_COL = 51
+LEFT_BOUND_COL = 55
+BOT_BOUND_COL = 40
+RIGHT_BOUND_COL = 35
+COL1 = 47
+MCOL = 49
+LCOL = 0
+BOUND_WIDTH = 3.0
+DRAW = 0
+PUSH = 1
+RELEASE = 2
+ENTER = 3
+LEAVE = 4
+MOUSE = 5
+FOCUS = 6
+UNFOCUS = 7
+KEYBOARD = 8
+STEP = 9
+MOVE = 10
+FONT_NAME = 'Helvetica'
+FONT_BOLDNAME = 'Helvetica-Bold'
+FONT_ITALICNAME = 'Helvetica-Oblique'
+FONT_FIXEDNAME = 'Courier'
+FONT_ICONNAME = 'Icon'
+SMALL_FONT = 8.0
+NORMAL_FONT = 11.0
+LARGE_FONT = 20.0
+NORMAL_STYLE = 0
+BOLD_STYLE = 1
+ITALIC_STYLE = 2
+FIXED_STYLE = 3
+ENGRAVED_STYLE = 4
+ICON_STYLE = 5
+BITMAP = 3
+NORMAL_BITMAP = 0
+BITMAP_BOXTYPE = NO_BOX
+BITMAP_COL1 = 0
+BITMAP_COL2 = COL1
+BITMAP_LCOL = LCOL
+BITMAP_ALIGN = ALIGN_BOTTOM
+BITMAP_MAXSIZE = 128*128
+BITMAP_BW = BOUND_WIDTH
+BOX = 1
+BOX_BOXTYPE = UP_BOX
+BOX_COL1 = COL1
+BOX_LCOL = LCOL
+BOX_ALIGN = ALIGN_CENTER
+BOX_BW = BOUND_WIDTH
+BROWSER = 71
+NORMAL_BROWSER = 0
+SELECT_BROWSER = 1
+HOLD_BROWSER = 2
+MULTI_BROWSER = 3
+BROWSER_BOXTYPE = DOWN_BOX
+BROWSER_COL1 = COL1
+BROWSER_COL2 = 3
+BROWSER_LCOL = LCOL
+BROWSER_ALIGN = ALIGN_BOTTOM
+BROWSER_SLCOL = COL1
+BROWSER_BW = BOUND_WIDTH
+BROWSER_LINELENGTH = 128
+BROWSER_MAXLINE = 512
+BUTTON = 11
+NORMAL_BUTTON = 0
+PUSH_BUTTON = 1
+RADIO_BUTTON = 2
+HIDDEN_BUTTON = 3
+TOUCH_BUTTON = 4
+INOUT_BUTTON = 5
+RETURN_BUTTON = 6
+if _v20:
+ HIDDEN_RET_BUTTON = 7
+BUTTON_BOXTYPE = UP_BOX
+BUTTON_COL1 = COL1
+BUTTON_COL2 = COL1
+BUTTON_LCOL = LCOL
+BUTTON_ALIGN = ALIGN_CENTER
+BUTTON_MCOL1 = MCOL
+BUTTON_MCOL2 = MCOL
+BUTTON_BW = BOUND_WIDTH
+if _v20:
+ CHART = 4
+ BAR_CHART = 0
+ HORBAR_CHART = 1
+ LINE_CHART = 2
+ FILLED_CHART = 3
+ SPIKE_CHART = 4
+ PIE_CHART = 5
+ SPECIALPIE_CHART = 6
+ CHART_BOXTYPE = BORDER_BOX
+ CHART_COL1 = COL1
+ CHART_LCOL = LCOL
+ CHART_ALIGN = ALIGN_BOTTOM
+ CHART_BW = BOUND_WIDTH
+ CHART_MAX = 128
+CHOICE = 42
+NORMAL_CHOICE = 0
+CHOICE_BOXTYPE = DOWN_BOX
+CHOICE_COL1 = COL1
+CHOICE_COL2 = LCOL
+CHOICE_LCOL = LCOL
+CHOICE_ALIGN = ALIGN_LEFT
+CHOICE_BW = BOUND_WIDTH
+CHOICE_MCOL = MCOL
+CHOICE_MAXITEMS = 128
+CHOICE_MAXSTR = 64
+CLOCK = 61
+SQUARE_CLOCK = 0
+ROUND_CLOCK = 1
+CLOCK_BOXTYPE = UP_BOX
+CLOCK_COL1 = 37
+CLOCK_COL2 = 42
+CLOCK_LCOL = LCOL
+CLOCK_ALIGN = ALIGN_BOTTOM
+CLOCK_TOPCOL = COL1
+CLOCK_BW = BOUND_WIDTH
+COUNTER = 25
+NORMAL_COUNTER = 0
+SIMPLE_COUNTER = 1
+COUNTER_BOXTYPE = UP_BOX
+COUNTER_COL1 = COL1
+COUNTER_COL2 = 4
+COUNTER_LCOL = LCOL
+COUNTER_ALIGN = ALIGN_BOTTOM
+if _v20:
+ COUNTER_BW = BOUND_WIDTH
+else:
+ DEFAULT = 51
+ RETURN_DEFAULT = 0
+ ALWAYS_DEFAULT = 1
+DIAL = 22
+NORMAL_DIAL = 0
+LINE_DIAL = 1
+DIAL_BOXTYPE = NO_BOX
+DIAL_COL1 = COL1
+DIAL_COL2 = 37
+DIAL_LCOL = LCOL
+DIAL_ALIGN = ALIGN_BOTTOM
+DIAL_TOPCOL = COL1
+DIAL_BW = BOUND_WIDTH
+FREE = 101
+NORMAL_FREE = 1
+SLEEPING_FREE = 2
+INPUT_FREE = 3
+CONTINUOUS_FREE = 4
+ALL_FREE = 5
+INPUT = 31
+NORMAL_INPUT = 0
+if _v20:
+ FLOAT_INPUT = 1
+ INT_INPUT = 2
+ HIDDEN_INPUT = 3
+ if _v21:
+ MULTILINE_INPUT = 4
+ SECRET_INPUT = 5
+else:
+ ALWAYS_INPUT = 1
+INPUT_BOXTYPE = DOWN_BOX
+INPUT_COL1 = 13
+INPUT_COL2 = 5
+INPUT_LCOL = LCOL
+INPUT_ALIGN = ALIGN_LEFT
+INPUT_TCOL = LCOL
+INPUT_CCOL = 4
+INPUT_BW = BOUND_WIDTH
+INPUT_MAX = 128
+LIGHTBUTTON = 12
+LIGHTBUTTON_BOXTYPE = UP_BOX
+LIGHTBUTTON_COL1 = 39
+LIGHTBUTTON_COL2 = 3
+LIGHTBUTTON_LCOL = LCOL
+LIGHTBUTTON_ALIGN = ALIGN_CENTER
+LIGHTBUTTON_TOPCOL = COL1
+LIGHTBUTTON_MCOL = MCOL
+LIGHTBUTTON_BW1 = BOUND_WIDTH
+LIGHTBUTTON_BW2 = BOUND_WIDTH/2.0
+LIGHTBUTTON_MINSIZE = 12.0
+MENU = 41
+TOUCH_MENU = 0
+PUSH_MENU = 1
+MENU_BOXTYPE = BORDER_BOX
+MENU_COL1 = 55
+MENU_COL2 = 37
+MENU_LCOL = LCOL
+MENU_ALIGN = ALIGN_CENTER
+MENU_BW = BOUND_WIDTH
+MENU_MAX = 300
+POSITIONER = 23
+NORMAL_POSITIONER = 0
+POSITIONER_BOXTYPE = DOWN_BOX
+POSITIONER_COL1 = COL1
+POSITIONER_COL2 = 1
+POSITIONER_LCOL = LCOL
+POSITIONER_ALIGN = ALIGN_BOTTOM
+POSITIONER_BW = BOUND_WIDTH
+ROUNDBUTTON = 13
+ROUNDBUTTON_BOXTYPE = NO_BOX
+ROUNDBUTTON_COL1 = 7
+ROUNDBUTTON_COL2 = 3
+ROUNDBUTTON_LCOL = LCOL
+ROUNDBUTTON_ALIGN = ALIGN_CENTER
+ROUNDBUTTON_TOPCOL = COL1
+ROUNDBUTTON_MCOL = MCOL
+ROUNDBUTTON_BW = BOUND_WIDTH
+SLIDER = 21
+VALSLIDER = 24
+VERT_SLIDER = 0
+HOR_SLIDER = 1
+VERT_FILL_SLIDER = 2
+HOR_FILL_SLIDER = 3
+VERT_NICE_SLIDER = 4
+HOR_NICE_SLIDER = 5
+SLIDER_BOXTYPE = DOWN_BOX
+SLIDER_COL1 = COL1
+SLIDER_COL2 = COL1
+SLIDER_LCOL = LCOL
+SLIDER_ALIGN = ALIGN_BOTTOM
+SLIDER_BW1 = BOUND_WIDTH
+SLIDER_BW2 = BOUND_WIDTH*0.75
+SLIDER_FINE = 0.05
+SLIDER_WIDTH = 0.08
+TEXT = 2
+NORMAL_TEXT = 0
+TEXT_BOXTYPE = NO_BOX
+TEXT_COL1 = COL1
+TEXT_LCOL = LCOL
+TEXT_ALIGN = ALIGN_LEFT
+TEXT_BW = BOUND_WIDTH
+TIMER = 62
+NORMAL_TIMER = 0
+VALUE_TIMER = 1
+HIDDEN_TIMER = 2
+TIMER_BOXTYPE = DOWN_BOX
+TIMER_COL1 = COL1
+TIMER_COL2 = 1
+TIMER_LCOL = LCOL
+TIMER_ALIGN = ALIGN_CENTER
+TIMER_BW = BOUND_WIDTH
+TIMER_BLINKRATE = 0.2
diff --git a/sys/lib/python/plat-irix5/GET.py b/sys/lib/python/plat-irix5/GET.py
new file mode 100755
index 000000000..9c3d7d695
--- /dev/null
+++ b/sys/lib/python/plat-irix5/GET.py
@@ -0,0 +1,59 @@
+# Symbols from <gl/get.h>
+
+BCKBUFFER = 0x1
+FRNTBUFFER = 0x2
+DRAWZBUFFER = 0x4
+DMRGB = 0
+DMSINGLE = 1
+DMDOUBLE = 2
+DMRGBDOUBLE = 5
+HZ30 = 0
+HZ60 = 1
+NTSC = 2
+HDTV = 3
+VGA = 4
+IRIS3K = 5
+PR60 = 6
+PAL = 9
+HZ30_SG = 11
+A343 = 14
+STR_RECT = 15
+VOF0 = 16
+VOF1 = 17
+VOF2 = 18
+VOF3 = 19
+SGI0 = 20
+SGI1 = 21
+SGI2 = 22
+HZ72 = 23
+GL_VIDEO_REG = 0x00800000
+GLV_GENLOCK = 0x00000001
+GLV_UNBLANK = 0x00000002
+GLV_SRED = 0x00000004
+GLV_SGREEN = 0x00000008
+GLV_SBLUE = 0x00000010
+GLV_SALPHA = 0x00000020
+GLV_TTLGENLOCK = 0x00000080
+GLV_TTLSYNC = GLV_TTLGENLOCK
+GLV_GREENGENLOCK = 0x0000100
+LEFTPLANE = 0x0001
+RIGHTPLANE = 0x0002
+BOTTOMPLANE = 0x0004
+TOPPLANE = 0x0008
+NEARPLANE = 0x0010
+FARPLANE = 0x0020
+## GETDEF = __GL_GET_H__
+NOBUFFER = 0x0
+BOTHBUFFERS = 0x3
+DMINTENSITYSINGLE = 3
+DMINTENSITYDOUBLE = 4
+MONSPECIAL = 0x20
+HZ50 = 3
+MONA = 5
+MONB = 6
+MONC = 7
+MOND = 8
+MON_ALL = 12
+MON_GEN_ALL = 13
+CMAPMULTI = 0
+CMAPONE = 1
diff --git a/sys/lib/python/plat-irix5/GL.py b/sys/lib/python/plat-irix5/GL.py
new file mode 100755
index 000000000..9f02f65f3
--- /dev/null
+++ b/sys/lib/python/plat-irix5/GL.py
@@ -0,0 +1,393 @@
+NULL = 0
+FALSE = 0
+TRUE = 1
+ATTRIBSTACKDEPTH = 10
+VPSTACKDEPTH = 8
+MATRIXSTACKDEPTH = 32
+NAMESTACKDEPTH = 1025
+STARTTAG = -2
+ENDTAG = -3
+BLACK = 0
+RED = 1
+GREEN = 2
+YELLOW = 3
+BLUE = 4
+MAGENTA = 5
+CYAN = 6
+WHITE = 7
+PUP_CLEAR = 0
+PUP_COLOR = 1
+PUP_BLACK = 2
+PUP_WHITE = 3
+NORMALDRAW = 0x010
+PUPDRAW = 0x020
+OVERDRAW = 0x040
+UNDERDRAW = 0x080
+CURSORDRAW = 0x100
+DUALDRAW = 0x200
+PATTERN_16 = 16
+PATTERN_32 = 32
+PATTERN_64 = 64
+PATTERN_16_SIZE = 16
+PATTERN_32_SIZE = 64
+PATTERN_64_SIZE = 256
+SRC_AUTO = 0
+SRC_FRONT = 1
+SRC_BACK = 2
+SRC_ZBUFFER = 3
+SRC_PUP = 4
+SRC_OVER = 5
+SRC_UNDER = 6
+SRC_FRAMEGRABBER = 7
+BF_ZERO = 0
+BF_ONE = 1
+BF_DC = 2
+BF_SC = 2
+BF_MDC = 3
+BF_MSC = 3
+BF_SA = 4
+BF_MSA = 5
+BF_DA = 6
+BF_MDA = 7
+BF_MIN_SA_MDA = 8
+AF_NEVER = 0
+AF_LESS = 1
+AF_EQUAL = 2
+AF_LEQUAL = 3
+AF_GREATER = 4
+AF_NOTEQUAL = 5
+AF_GEQUAL = 6
+AF_ALWAYS = 7
+ZF_NEVER = 0
+ZF_LESS = 1
+ZF_EQUAL = 2
+ZF_LEQUAL = 3
+ZF_GREATER = 4
+ZF_NOTEQUAL = 5
+ZF_GEQUAL = 6
+ZF_ALWAYS = 7
+ZSRC_DEPTH = 0
+ZSRC_COLOR = 1
+SMP_OFF = 0x0
+SMP_ON = 0x1
+SMP_SMOOTHER = 0x2
+SML_OFF = 0x0
+SML_ON = 0x1
+SML_SMOOTHER = 0x2
+SML_END_CORRECT = 0x4
+PYSM_OFF = 0
+PYSM_ON = 1
+PYSM_SHRINK = 2
+DT_OFF = 0
+DT_ON = 1
+PUP_NONE = 0
+PUP_GREY = 0x1
+PUP_BOX = 0x2
+PUP_CHECK = 0x4
+GLC_OLDPOLYGON = 0
+GLC_ZRANGEMAP = 1
+GLC_MQUEUERATE = 2
+GLC_SOFTATTACH = 3
+GLC_MANAGEBG = 4
+GLC_SLOWMAPCOLORS = 5
+GLC_INPUTCHANGEBUG = 6
+GLC_NOBORDERBUG = 7
+GLC_SET_VSYNC = 8
+GLC_GET_VSYNC = 9
+GLC_VSYNC_SLEEP = 10
+GLC_COMPATRATE = 15
+C16X1 = 0
+C16X2 = 1
+C32X1 = 2
+C32X2 = 3
+CCROSS = 4
+FLAT = 0
+GOURAUD = 1
+LO_ZERO = 0x0
+LO_AND = 0x1
+LO_ANDR = 0x2
+LO_SRC = 0x3
+LO_ANDI = 0x4
+LO_DST = 0x5
+LO_XOR = 0x6
+LO_OR = 0x7
+LO_NOR = 0x8
+LO_XNOR = 0x9
+LO_NDST = 0xa
+LO_ORR = 0xb
+LO_NSRC = 0xc
+LO_ORI = 0xd
+LO_NAND = 0xe
+LO_ONE = 0xf
+INFOCUSSCRN = -2
+ST_KEEP = 0
+ST_ZERO = 1
+ST_REPLACE = 2
+ST_INCR = 3
+ST_DECR = 4
+ST_INVERT = 5
+SF_NEVER = 0
+SF_LESS = 1
+SF_EQUAL = 2
+SF_LEQUAL = 3
+SF_GREATER = 4
+SF_NOTEQUAL = 5
+SF_GEQUAL = 6
+SF_ALWAYS = 7
+SS_OFF = 0
+SS_DEPTH = 1
+PYM_FILL = 1
+PYM_POINT = 2
+PYM_LINE = 3
+PYM_HOLLOW = 4
+PYM_LINE_FAST = 5
+FG_OFF = 0
+FG_ON = 1
+FG_DEFINE = 2
+FG_VTX_EXP = 2
+FG_VTX_LIN = 3
+FG_PIX_EXP = 4
+FG_PIX_LIN = 5
+FG_VTX_EXP2 = 6
+FG_PIX_EXP2 = 7
+PM_SHIFT = 0
+PM_EXPAND = 1
+PM_C0 = 2
+PM_C1 = 3
+PM_ADD24 = 4
+PM_SIZE = 5
+PM_OFFSET = 6
+PM_STRIDE = 7
+PM_TTOB = 8
+PM_RTOL = 9
+PM_ZDATA = 10
+PM_WARP = 11
+PM_RDX = 12
+PM_RDY = 13
+PM_CDX = 14
+PM_CDY = 15
+PM_XSTART = 16
+PM_YSTART = 17
+PM_VO1 = 1000
+NAUTO = 0
+NNORMALIZE = 1
+AC_CLEAR = 0
+AC_ACCUMULATE = 1
+AC_CLEAR_ACCUMULATE = 2
+AC_RETURN = 3
+AC_MULT = 4
+AC_ADD = 5
+CP_OFF = 0
+CP_ON = 1
+CP_DEFINE = 2
+SB_RESET = 0
+SB_TRACK = 1
+SB_HOLD = 2
+RD_FREEZE = 0x00000001
+RD_ALPHAONE = 0x00000002
+RD_IGNORE_UNDERLAY = 0x00000004
+RD_IGNORE_OVERLAY = 0x00000008
+RD_IGNORE_PUP = 0x00000010
+RD_OFFSCREEN = 0x00000020
+GD_XPMAX = 0
+GD_YPMAX = 1
+GD_XMMAX = 2
+GD_YMMAX = 3
+GD_ZMIN = 4
+GD_ZMAX = 5
+GD_BITS_NORM_SNG_RED = 6
+GD_BITS_NORM_SNG_GREEN = 7
+GD_BITS_NORM_SNG_BLUE = 8
+GD_BITS_NORM_DBL_RED = 9
+GD_BITS_NORM_DBL_GREEN = 10
+GD_BITS_NORM_DBL_BLUE = 11
+GD_BITS_NORM_SNG_CMODE = 12
+GD_BITS_NORM_DBL_CMODE = 13
+GD_BITS_NORM_SNG_MMAP = 14
+GD_BITS_NORM_DBL_MMAP = 15
+GD_BITS_NORM_ZBUFFER = 16
+GD_BITS_OVER_SNG_CMODE = 17
+GD_BITS_UNDR_SNG_CMODE = 18
+GD_BITS_PUP_SNG_CMODE = 19
+GD_BITS_NORM_SNG_ALPHA = 21
+GD_BITS_NORM_DBL_ALPHA = 22
+GD_BITS_CURSOR = 23
+GD_OVERUNDER_SHARED = 24
+GD_BLEND = 25
+GD_CIFRACT = 26
+GD_CROSSHAIR_CINDEX = 27
+GD_DITHER = 28
+GD_LINESMOOTH_CMODE = 30
+GD_LINESMOOTH_RGB = 31
+GD_LOGICOP = 33
+GD_NSCRNS = 35
+GD_NURBS_ORDER = 36
+GD_NBLINKS = 37
+GD_NVERTEX_POLY = 39
+GD_PATSIZE_64 = 40
+GD_PNTSMOOTH_CMODE = 41
+GD_PNTSMOOTH_RGB = 42
+GD_PUP_TO_OVERUNDER = 43
+GD_READSOURCE = 44
+GD_READSOURCE_ZBUFFER = 48
+GD_STEREO = 50
+GD_SUBPIXEL_LINE = 51
+GD_SUBPIXEL_PNT = 52
+GD_SUBPIXEL_POLY = 53
+GD_TRIMCURVE_ORDER = 54
+GD_WSYS = 55
+GD_ZDRAW_GEOM = 57
+GD_ZDRAW_PIXELS = 58
+GD_SCRNTYPE = 61
+GD_TEXTPORT = 62
+GD_NMMAPS = 63
+GD_FRAMEGRABBER = 64
+GD_TIMERHZ = 66
+GD_DBBOX = 67
+GD_AFUNCTION = 68
+GD_ALPHA_OVERUNDER = 69
+GD_BITS_ACBUF = 70
+GD_BITS_ACBUF_HW = 71
+GD_BITS_STENCIL = 72
+GD_CLIPPLANES = 73
+GD_FOGVERTEX = 74
+GD_LIGHTING_TWOSIDE = 76
+GD_POLYMODE = 77
+GD_POLYSMOOTH = 78
+GD_SCRBOX = 79
+GD_TEXTURE = 80
+GD_FOGPIXEL = 81
+GD_TEXTURE_PERSP = 82
+GD_MUXPIPES = 83
+GD_NOLIMIT = -2
+GD_WSYS_NONE = 0
+GD_WSYS_4S = 1
+GD_SCRNTYPE_WM = 0
+GD_SCRNTYPE_NOWM = 1
+N_PIXEL_TOLERANCE = 1
+N_CULLING = 2
+N_DISPLAY = 3
+N_ERRORCHECKING = 4
+N_SUBDIVISIONS = 5
+N_S_STEPS = 6
+N_T_STEPS = 7
+N_TILES = 8
+N_TMP1 = 9
+N_TMP2 = 10
+N_TMP3 = 11
+N_TMP4 = 12
+N_TMP5 = 13
+N_TMP6 = 14
+N_FILL = 1.0
+N_OUTLINE_POLY = 2.0
+N_OUTLINE_PATCH = 5.0
+N_ISOLINE_S = 12.0
+N_ST = 0x8
+N_STW = 0xd
+N_XYZ = 0x4c
+N_XYZW = 0x51
+N_TEX = 0x88
+N_TEXW = 0x8d
+N_RGBA = 0xd0
+N_RGBAW = 0xd5
+N_P2D = 0x8
+N_P2DR = 0xd
+N_V3D = 0x4c
+N_V3DR = 0x51
+N_T2D = 0x88
+N_T2DR = 0x8d
+N_C4D = 0xd0
+N_C4DR = 0xd5
+LMNULL = 0.0
+MSINGLE = 0
+MPROJECTION = 1
+MVIEWING = 2
+MTEXTURE = 3
+MAXLIGHTS = 8
+MAXRESTRICTIONS = 4
+DEFMATERIAL = 0
+EMISSION = 1
+AMBIENT = 2
+DIFFUSE = 3
+SPECULAR = 4
+SHININESS = 5
+COLORINDEXES = 6
+ALPHA = 7
+DEFLIGHT = 100
+LCOLOR = 101
+POSITION = 102
+SPOTDIRECTION = 103
+SPOTLIGHT = 104
+DEFLMODEL = 200
+LOCALVIEWER = 201
+ATTENUATION = 202
+ATTENUATION2 = 203
+TWOSIDE = 204
+MATERIAL = 1000
+BACKMATERIAL = 1001
+LIGHT0 = 1100
+LIGHT1 = 1101
+LIGHT2 = 1102
+LIGHT3 = 1103
+LIGHT4 = 1104
+LIGHT5 = 1105
+LIGHT6 = 1106
+LIGHT7 = 1107
+LMODEL = 1200
+LMC_COLOR = 0
+LMC_EMISSION = 1
+LMC_AMBIENT = 2
+LMC_DIFFUSE = 3
+LMC_SPECULAR = 4
+LMC_AD = 5
+LMC_NULL = 6
+TX_MINFILTER = 0x100
+TX_MAGFILTER = 0x200
+TX_WRAP = 0x300
+TX_WRAP_S = 0x310
+TX_WRAP_T = 0x320
+TX_TILE = 0x400
+TX_BORDER = 0x500
+TX_NULL = 0x000
+TX_POINT = 0x110
+TX_BILINEAR = 0x220
+TX_MIPMAP = 0x120
+TX_MIPMAP_POINT = 0x121
+TX_MIPMAP_LINEAR = 0x122
+TX_MIPMAP_BILINEAR = 0x123
+TX_MIPMAP_TRILINEAR = 0x124
+TX_REPEAT = 0x301
+TX_CLAMP = 0x302
+TX_SELECT = 0x303
+TX_TEXTURE_0 = 0
+TV_MODULATE = 0x101
+TV_BLEND = 0x102
+TV_DECAL = 0x103
+TV_COLOR = 0x200
+TV_NULL = 0x000
+TV_ENV0 = 0
+TX_S = 0
+TX_T = 1
+TG_OFF = 0
+TG_ON = 1
+TG_CONTOUR = 2
+TG_LINEAR = 3
+TG_SPHEREMAP = 4
+TG_REFRACTMAP = 5
+DGLSINK = 0
+DGLLOCAL = 1
+DGLTSOCKET = 2
+DGL4DDN = 3
+PUP_CURSOR = PUP_COLOR
+FATAL = 1
+WARNING = 2
+ASK_CONT = 3
+ASK_RESTART = 4
+XMAXSCREEN = 1279
+YMAXSCREEN = 1023
+XMAXMEDIUM = 1023
+YMAXMEDIUM = 767
+XMAX170 = 645
+YMAX170 = 484
+XMAXPAL = 779
+YMAXPAL = 574
diff --git a/sys/lib/python/plat-irix5/GLWS.py b/sys/lib/python/plat-irix5/GLWS.py
new file mode 100755
index 000000000..69dab7143
--- /dev/null
+++ b/sys/lib/python/plat-irix5/GLWS.py
@@ -0,0 +1,12 @@
+NOERROR = 0
+NOCONTEXT = -1
+NODISPLAY = -2
+NOWINDOW = -3
+NOGRAPHICS = -4
+NOTTOP = -5
+NOVISUAL = -6
+BUFSIZE = -7
+BADWINDOW = -8
+ALREADYBOUND = -100
+BINDFAILED = -101
+SETFAILED = -102
diff --git a/sys/lib/python/plat-irix5/IN.py b/sys/lib/python/plat-irix5/IN.py
new file mode 100755
index 000000000..2d6789201
--- /dev/null
+++ b/sys/lib/python/plat-irix5/IN.py
@@ -0,0 +1,141 @@
+# Generated by h2py from /usr/include/netinet/in.h
+
+# Included from sys/endian.h
+LITTLE_ENDIAN = 1234
+BIG_ENDIAN = 4321
+PDP_ENDIAN = 3412
+BYTE_ORDER = BIG_ENDIAN
+BYTE_ORDER = LITTLE_ENDIAN
+def ntohl(x): return (x)
+
+def ntohs(x): return (x)
+
+def htonl(x): return (x)
+
+def htons(x): return (x)
+
+def htonl(x): return ntohl(x)
+
+def htons(x): return ntohs(x)
+
+
+# Included from sys/bsd_types.h
+
+# Included from sys/mkdev.h
+ONBITSMAJOR = 7
+ONBITSMINOR = 8
+OMAXMAJ = 0x7f
+OMAXMIN = 0xff
+NBITSMAJOR = 14
+NBITSMINOR = 18
+MAXMAJ = 0x1ff
+MAXMIN = 0x3ffff
+OLDDEV = 0
+NEWDEV = 1
+MKDEV_VER = NEWDEV
+def major(dev): return __major(MKDEV_VER, dev)
+
+def minor(dev): return __minor(MKDEV_VER, dev)
+
+
+# Included from sys/select.h
+FD_SETSIZE = 1024
+NBBY = 8
+IPPROTO_IP = 0
+IPPROTO_ICMP = 1
+IPPROTO_IGMP = 2
+IPPROTO_GGP = 3
+IPPROTO_ENCAP = 4
+IPPROTO_TCP = 6
+IPPROTO_EGP = 8
+IPPROTO_PUP = 12
+IPPROTO_UDP = 17
+IPPROTO_IDP = 22
+IPPROTO_TP = 29
+IPPROTO_XTP = 36
+IPPROTO_HELLO = 63
+IPPROTO_ND = 77
+IPPROTO_EON = 80
+IPPROTO_RAW = 255
+IPPROTO_MAX = 256
+IPPORT_RESERVED = 1024
+IPPORT_USERRESERVED = 5000
+IPPORT_MAXPORT = 65535
+def IN_CLASSA(i): return (((long)(i) & 0x80000000) == 0)
+
+IN_CLASSA_NET = 0xff000000
+IN_CLASSA_NSHIFT = 24
+IN_CLASSA_HOST = 0x00ffffff
+IN_CLASSA_MAX = 128
+def IN_CLASSB(i): return (((long)(i) & 0xc0000000) == 0x80000000)
+
+IN_CLASSB_NET = 0xffff0000
+IN_CLASSB_NSHIFT = 16
+IN_CLASSB_HOST = 0x0000ffff
+IN_CLASSB_MAX = 65536
+def IN_CLASSC(i): return (((long)(i) & 0xe0000000) == 0xc0000000)
+
+IN_CLASSC_NET = 0xffffff00
+IN_CLASSC_NSHIFT = 8
+IN_CLASSC_HOST = 0x000000ff
+def IN_CLASSD(i): return (((long)(i) & 0xf0000000) == 0xe0000000)
+
+IN_CLASSD_NET = 0xf0000000
+IN_CLASSD_NSHIFT = 28
+IN_CLASSD_HOST = 0x0fffffff
+def IN_MULTICAST(i): return IN_CLASSD(i)
+
+def IN_EXPERIMENTAL(i): return (((long)(i) & 0xf0000000) == 0xf0000000)
+
+def IN_BADCLASS(i): return (((long)(i) & 0xf0000000) == 0xf0000000)
+
+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_MULTICAST_IF = 2
+IP_MULTICAST_TTL = 3
+IP_MULTICAST_LOOP = 4
+IP_ADD_MEMBERSHIP = 5
+IP_DROP_MEMBERSHIP = 6
+IP_HDRINCL = 7
+IP_TOS = 8
+IP_TTL = 9
+IP_RECVOPTS = 10
+IP_RECVRETOPTS = 11
+IP_RECVDSTADDR = 12
+IP_RETOPTS = 13
+IP_OPTIONS = 1
+IP_HDRINCL = 2
+IP_TOS = 3
+IP_TTL = 4
+IP_RECVOPTS = 5
+IP_RECVRETOPTS = 6
+IP_RECVDSTADDR = 7
+IP_RETOPTS = 8
+IP_MULTICAST_IF = 20
+IP_MULTICAST_TTL = 21
+IP_MULTICAST_LOOP = 22
+IP_ADD_MEMBERSHIP = 23
+IP_DROP_MEMBERSHIP = 24
+IRIX4_IP_OPTIONS = 1
+IRIX4_IP_MULTICAST_IF = 2
+IRIX4_IP_MULTICAST_TTL = 3
+IRIX4_IP_MULTICAST_LOOP = 4
+IRIX4_IP_ADD_MEMBERSHIP = 5
+IRIX4_IP_DROP_MEMBERSHIP = 6
+IRIX4_IP_HDRINCL = 7
+IRIX4_IP_TOS = 8
+IRIX4_IP_TTL = 9
+IRIX4_IP_RECVOPTS = 10
+IRIX4_IP_RECVRETOPTS = 11
+IRIX4_IP_RECVDSTADDR = 12
+IRIX4_IP_RETOPTS = 13
+IP_DEFAULT_MULTICAST_TTL = 1
+IP_DEFAULT_MULTICAST_LOOP = 1
+IP_MAX_MEMBERSHIPS = 20
diff --git a/sys/lib/python/plat-irix5/IOCTL.py b/sys/lib/python/plat-irix5/IOCTL.py
new file mode 100755
index 000000000..cec3c3f6a
--- /dev/null
+++ b/sys/lib/python/plat-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/sys/lib/python/plat-irix5/SV.py b/sys/lib/python/plat-irix5/SV.py
new file mode 100755
index 000000000..db8efe52d
--- /dev/null
+++ b/sys/lib/python/plat-irix5/SV.py
@@ -0,0 +1,120 @@
+NTSC_XMAX = 640
+NTSC_YMAX = 480
+PAL_XMAX = 768
+PAL_YMAX = 576
+BLANKING_BUFFER_SIZE = 2
+
+MAX_SOURCES = 2
+
+# mode parameter for Bind calls
+IN_OFF = 0 # No Video
+IN_OVER = 1 # Video over graphics
+IN_UNDER = 2 # Video under graphics
+IN_REPLACE = 3 # Video replaces entire win
+
+# mode parameters for LoadMap calls. Specifies buffer, always 256 entries
+INPUT_COLORMAP = 0 # tuples of 8-bit RGB
+CHROMA_KEY_MAP = 1 # tuples of 8-bit RGB
+COLOR_SPACE_MAP = 2 # tuples of 8-bit RGB
+GAMMA_MAP = 3 # tuples of 24-bit red values
+
+# mode parameters for UseExclusive calls
+INPUT = 0
+OUTPUT = 1
+IN_OUT = 2
+
+# Format constants for the capture routines
+RGB8_FRAMES = 0 # noninterleaved 8 bit 3:2:3 RBG fields
+RGB32_FRAMES = 1 # 32-bit 8:8:8 RGB frames
+YUV411_FRAMES = 2 # interleaved, 8:2:2 YUV format
+YUV411_FRAMES_AND_BLANKING_BUFFER = 3
+
+#
+# sv.SetParam is passed variable length argument lists,
+# consisting of <name, value> pairs. The following
+# constants identify argument names.
+#
+_NAME_BASE = 1000
+SOURCE = (_NAME_BASE + 0)
+SOURCE1 = 0
+SOURCE2 = 1
+SOURCE3 = 2
+COLOR = (_NAME_BASE + 1)
+DEFAULT_COLOR = 0
+USER_COLOR = 1
+MONO = 2
+OUTPUTMODE = (_NAME_BASE + 2)
+LIVE_OUTPUT = 0
+STILL24_OUT = 1
+FREEZE = (_NAME_BASE + 3)
+DITHER = (_NAME_BASE + 4)
+OUTPUT_FILTER = (_NAME_BASE + 5)
+HUE = (_NAME_BASE + 6)
+GENLOCK = (_NAME_BASE + 7)
+GENLOCK_OFF = 0
+GENLOCK_ON = 1
+GENLOCK_HOUSE = 2
+BROADCAST = (_NAME_BASE + 8)
+NTSC = 0
+PAL = 1
+VIDEO_MODE = (_NAME_BASE + 9)
+COMP = 0
+SVIDEO = 1
+INPUT_BYPASS = (_NAME_BASE + 10)
+FIELDDROP = (_NAME_BASE + 11)
+SLAVE = (_NAME_BASE + 12)
+APERTURE_FACTOR = (_NAME_BASE + 13)
+AFACTOR_0 = 0
+AFACTOR_QTR = 1
+AFACTOR_HLF = 2
+AFACTOR_ONE = 3
+CORING = (_NAME_BASE + 14)
+COR_OFF = 0
+COR_1LSB = 1
+COR_2LSB = 2
+COR_3LSB = 3
+APERTURE_BANDPASS = (_NAME_BASE + 15)
+ABAND_F0 = 0
+ABAND_F1 = 1
+ABAND_F2 = 2
+ABAND_F3 = 3
+PREFILTER = (_NAME_BASE + 16)
+CHROMA_TRAP = (_NAME_BASE + 17)
+CK_THRESHOLD = (_NAME_BASE + 18)
+PAL_SENSITIVITY = (_NAME_BASE + 19)
+GAIN_CONTROL = (_NAME_BASE + 20)
+GAIN_SLOW = 0
+GAIN_MEDIUM = 1
+GAIN_FAST = 2
+GAIN_FROZEN = 3
+AUTO_CKILL = (_NAME_BASE + 21)
+VTR_MODE = (_NAME_BASE + 22)
+VTR_INPUT = 0
+CAMERA_INPUT = 1
+LUMA_DELAY = (_NAME_BASE + 23)
+VNOISE = (_NAME_BASE + 24)
+VNOISE_NORMAL = 0
+VNOISE_SEARCH = 1
+VNOISE_AUTO = 2
+VNOISE_BYPASS = 3
+CHCV_PAL = (_NAME_BASE + 25)
+CHCV_NTSC = (_NAME_BASE + 26)
+CCIR_LEVELS = (_NAME_BASE + 27)
+STD_CHROMA = (_NAME_BASE + 28)
+DENC_VTBYPASS = (_NAME_BASE + 29)
+FAST_TIMECONSTANT = (_NAME_BASE + 30)
+GENLOCK_DELAY = (_NAME_BASE + 31)
+PHASE_SYNC = (_NAME_BASE + 32)
+VIDEO_OUTPUT = (_NAME_BASE + 33)
+CHROMA_PHASEOUT = (_NAME_BASE + 34)
+CHROMA_CENTER = (_NAME_BASE + 35)
+YUV_TO_RGB_INVERT = (_NAME_BASE + 36)
+SOURCE1_BROADCAST = (_NAME_BASE + 37)
+SOURCE1_MODE = (_NAME_BASE + 38)
+SOURCE2_BROADCAST = (_NAME_BASE + 39)
+SOURCE2_MODE = (_NAME_BASE + 40)
+SOURCE3_BROADCAST = (_NAME_BASE + 41)
+SOURCE3_MODE = (_NAME_BASE + 42)
+SIGNAL_STD = (_NAME_BASE + 43)
+NOSIGNAL = 2
+SIGNAL_COLOR = (_NAME_BASE + 44)
diff --git a/sys/lib/python/plat-irix5/WAIT.py b/sys/lib/python/plat-irix5/WAIT.py
new file mode 100755
index 000000000..bfd0133e8
--- /dev/null
+++ b/sys/lib/python/plat-irix5/WAIT.py
@@ -0,0 +1,14 @@
+# Generated by h2py from /usr/include/sys/wait.h
+_WSTOPPED = 0177
+WNOHANG = 0100
+WEXITED = 0001
+WTRAPPED = 0002
+WSTOPPED = 0004
+WCONTINUED = 0010
+WNOWAIT = 0200
+WOPTMASK = (WEXITED|WTRAPPED|WSTOPPED|WCONTINUED|WNOHANG|WNOWAIT)
+WSTOPFLG = 0177
+WCONTFLG = 0177777
+WCOREFLAG = 0200
+WSIGMASK = 0177
+WUNTRACED = 0004
diff --git a/sys/lib/python/plat-irix5/cddb.py b/sys/lib/python/plat-irix5/cddb.py
new file mode 100755
index 000000000..7b2711f0b
--- /dev/null
+++ b/sys/lib/python/plat-irix5/cddb.py
@@ -0,0 +1,204 @@
+# This file implements a class which forms an interface to the .cddb
+# directory that is maintained by SGI's cdman program.
+#
+# Usage is as follows:
+#
+# import readcd
+# r = readcd.Readcd()
+# c = Cddb(r.gettrackinfo())
+#
+# Now you can use c.artist, c.title and c.track[trackno] (where trackno
+# starts at 1). When the CD is not recognized, all values will be the empty
+# string.
+# It is also possible to set the above mentioned variables to new values.
+# You can then use c.write() to write out the changed values to the
+# .cdplayerrc file.
+
+import string, posix, os
+
+_cddbrc = '.cddb'
+_DB_ID_NTRACKS = 5
+_dbid_map = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ@_=+abcdefghijklmnopqrstuvwxyz'
+def _dbid(v):
+ if v >= len(_dbid_map):
+ return string.zfill(v, 2)
+ else:
+ return _dbid_map[v]
+
+def tochash(toc):
+ if type(toc) == type(''):
+ tracklist = []
+ for i in range(2, len(toc), 4):
+ tracklist.append((None,
+ (int(toc[i:i+2]),
+ int(toc[i+2:i+4]))))
+ else:
+ tracklist = toc
+ ntracks = len(tracklist)
+ hash = _dbid((ntracks >> 4) & 0xF) + _dbid(ntracks & 0xF)
+ if ntracks <= _DB_ID_NTRACKS:
+ nidtracks = ntracks
+ else:
+ nidtracks = _DB_ID_NTRACKS - 1
+ min = 0
+ sec = 0
+ for track in tracklist:
+ start, length = track
+ min = min + length[0]
+ sec = sec + length[1]
+ min = min + sec / 60
+ sec = sec % 60
+ hash = hash + _dbid(min) + _dbid(sec)
+ for i in range(nidtracks):
+ start, length = tracklist[i]
+ hash = hash + _dbid(length[0]) + _dbid(length[1])
+ return hash
+
+class Cddb:
+ def __init__(self, tracklist):
+ if os.environ.has_key('CDDB_PATH'):
+ path = os.environ['CDDB_PATH']
+ cddb_path = path.split(',')
+ else:
+ home = os.environ['HOME']
+ cddb_path = [home + '/' + _cddbrc]
+
+ self._get_id(tracklist)
+
+ for dir in cddb_path:
+ file = dir + '/' + self.id + '.rdb'
+ try:
+ f = open(file, 'r')
+ self.file = file
+ break
+ except IOError:
+ pass
+ ntracks = int(self.id[:2], 16)
+ self.artist = ''
+ self.title = ''
+ self.track = [None] + [''] * ntracks
+ self.trackartist = [None] + [''] * ntracks
+ self.notes = []
+ if not hasattr(self, 'file'):
+ return
+ import re
+ reg = re.compile(r'^([^.]*)\.([^:]*):[\t ]+(.*)')
+ while 1:
+ line = f.readline()
+ if not line:
+ break
+ match = reg.match(line)
+ if not match:
+ print 'syntax error in ' + file
+ continue
+ name1, name2, value = match.group(1, 2, 3)
+ if name1 == 'album':
+ if name2 == 'artist':
+ self.artist = value
+ elif name2 == 'title':
+ self.title = value
+ elif name2 == 'toc':
+ if not self.toc:
+ self.toc = value
+ if self.toc != value:
+ print 'toc\'s don\'t match'
+ elif name2 == 'notes':
+ self.notes.append(value)
+ elif name1[:5] == 'track':
+ try:
+ trackno = int(name1[5:])
+ except strings.atoi_error:
+ print 'syntax error in ' + file
+ continue
+ if trackno > ntracks:
+ print 'track number %r in file %r out of range' % (trackno, file)
+ continue
+ if name2 == 'title':
+ self.track[trackno] = value
+ elif name2 == 'artist':
+ self.trackartist[trackno] = value
+ f.close()
+ for i in range(2, len(self.track)):
+ track = self.track[i]
+ # if track title starts with `,', use initial part
+ # of previous track's title
+ if track and track[0] == ',':
+ try:
+ off = self.track[i - 1].index(',')
+ except ValueError:
+ pass
+ else:
+ self.track[i] = self.track[i-1][:off] \
+ + track
+
+ def _get_id(self, tracklist):
+ # fill in self.id and self.toc.
+ # if the argument is a string ending in .rdb, the part
+ # upto the suffix is taken as the id.
+ if type(tracklist) == type(''):
+ if tracklist[-4:] == '.rdb':
+ self.id = tracklist[:-4]
+ self.toc = ''
+ return
+ t = []
+ for i in range(2, len(tracklist), 4):
+ t.append((None, \
+ (int(tracklist[i:i+2]), \
+ int(tracklist[i+2:i+4]))))
+ tracklist = t
+ ntracks = len(tracklist)
+ self.id = _dbid((ntracks >> 4) & 0xF) + _dbid(ntracks & 0xF)
+ if ntracks <= _DB_ID_NTRACKS:
+ nidtracks = ntracks
+ else:
+ nidtracks = _DB_ID_NTRACKS - 1
+ min = 0
+ sec = 0
+ for track in tracklist:
+ start, length = track
+ min = min + length[0]
+ sec = sec + length[1]
+ min = min + sec / 60
+ sec = sec % 60
+ self.id = self.id + _dbid(min) + _dbid(sec)
+ for i in range(nidtracks):
+ start, length = tracklist[i]
+ self.id = self.id + _dbid(length[0]) + _dbid(length[1])
+ self.toc = string.zfill(ntracks, 2)
+ for track in tracklist:
+ start, length = track
+ self.toc = self.toc + string.zfill(length[0], 2) + \
+ string.zfill(length[1], 2)
+
+ def write(self):
+ import posixpath
+ if os.environ.has_key('CDDB_WRITE_DIR'):
+ dir = os.environ['CDDB_WRITE_DIR']
+ else:
+ dir = os.environ['HOME'] + '/' + _cddbrc
+ file = dir + '/' + self.id + '.rdb'
+ if posixpath.exists(file):
+ # make backup copy
+ posix.rename(file, file + '~')
+ f = open(file, 'w')
+ f.write('album.title:\t' + self.title + '\n')
+ f.write('album.artist:\t' + self.artist + '\n')
+ f.write('album.toc:\t' + self.toc + '\n')
+ for note in self.notes:
+ f.write('album.notes:\t' + note + '\n')
+ prevpref = None
+ for i in range(1, len(self.track)):
+ if self.trackartist[i]:
+ f.write('track%r.artist:\t%s\n' % (i, self.trackartist[i]))
+ track = self.track[i]
+ try:
+ off = track.index(',')
+ except ValuError:
+ prevpref = None
+ else:
+ if prevpref and track[:off] == prevpref:
+ track = track[off:]
+ else:
+ prevpref = track[:off]
+ f.write('track%r.title:\t%s\n' % (i, track))
+ f.close()
diff --git a/sys/lib/python/plat-irix5/cdplayer.py b/sys/lib/python/plat-irix5/cdplayer.py
new file mode 100755
index 000000000..1c0168f7d
--- /dev/null
+++ b/sys/lib/python/plat-irix5/cdplayer.py
@@ -0,0 +1,88 @@
+# This file implements a class which forms an interface to the .cdplayerrc
+# file that is maintained by SGI's cdplayer program.
+#
+# Usage is as follows:
+#
+# import readcd
+# r = readcd.Readcd()
+# c = Cdplayer(r.gettrackinfo())
+#
+# Now you can use c.artist, c.title and c.track[trackno] (where trackno
+# starts at 1). When the CD is not recognized, all values will be the empty
+# string.
+# It is also possible to set the above mentioned variables to new values.
+# You can then use c.write() to write out the changed values to the
+# .cdplayerrc file.
+
+cdplayerrc = '.cdplayerrc'
+
+class Cdplayer:
+ def __init__(self, tracklist):
+ import string
+ self.artist = ''
+ self.title = ''
+ if type(tracklist) == type(''):
+ t = []
+ for i in range(2, len(tracklist), 4):
+ t.append((None, \
+ (string.atoi(tracklist[i:i+2]), \
+ string.atoi(tracklist[i+2:i+4]))))
+ tracklist = t
+ self.track = [None] + [''] * len(tracklist)
+ self.id = 'd' + string.zfill(len(tracklist), 2)
+ for track in tracklist:
+ start, length = track
+ self.id = self.id + string.zfill(length[0], 2) + \
+ string.zfill(length[1], 2)
+ try:
+ import posix
+ f = open(posix.environ['HOME'] + '/' + cdplayerrc, 'r')
+ except IOError:
+ return
+ import re
+ reg = re.compile(r'^([^:]*):\t(.*)')
+ s = self.id + '.'
+ l = len(s)
+ while 1:
+ line = f.readline()
+ if line == '':
+ break
+ if line[:l] == s:
+ line = line[l:]
+ match = reg.match(line)
+ if not match:
+ print 'syntax error in ~/' + cdplayerrc
+ continue
+ name, value = match.group(1, 2)
+ if name == 'title':
+ self.title = value
+ elif name == 'artist':
+ self.artist = value
+ elif name[:5] == 'track':
+ trackno = string.atoi(name[6:])
+ self.track[trackno] = value
+ f.close()
+
+ def write(self):
+ import posix
+ filename = posix.environ['HOME'] + '/' + cdplayerrc
+ try:
+ old = open(filename, 'r')
+ except IOError:
+ old = open('/dev/null', 'r')
+ new = open(filename + '.new', 'w')
+ s = self.id + '.'
+ l = len(s)
+ while 1:
+ line = old.readline()
+ if line == '':
+ break
+ if line[:l] != s:
+ new.write(line)
+ new.write(self.id + '.title:\t' + self.title + '\n')
+ new.write(self.id + '.artist:\t' + self.artist + '\n')
+ for i in range(1, len(self.track)):
+ new.write('%s.track.%r:\t%s\n' % (self.id, i, self.track[i]))
+ old.close()
+ new.close()
+ posix.rename(filename + '.new', filename)
diff --git a/sys/lib/python/plat-irix5/flp.doc b/sys/lib/python/plat-irix5/flp.doc
new file mode 100755
index 000000000..1a2f374ae
--- /dev/null
+++ b/sys/lib/python/plat-irix5/flp.doc
@@ -0,0 +1,117 @@
+.SH
+Module flp
+.LP
+The flp module loads fl-forms from fd files, as generated
+by fdesign. The module is designed to be flexible enough to allow
+almost anything to be done with the loaded form.
+.LP
+Loadform defines
+two types of functions: functions to parse fd files and functions to
+create the forms from the templates returned by the parse functions.
+There are fairly low-level create functions that create single objects,
+and convenience routines that create complete forms, including callbacks,
+etc.
+.LP
+The exception flp.error is raised whenever an error occurs while parsing a forms
+definition file or creating a form.
+.SH 2
+Parsing functions
+.LP
+There are two parsing functions, parse_form() and parse_forms(). They
+take the following form:
+.LP
+.ft C
+ftuple = parse_form(filename, formname)
+.br
+ftdict = parse_forms(filename)
+.IP
+Parse_form parses a single form, and returns a tuple (ftmp, otmplist).
+Ftmp is a template for a form, otmplist is a list of templates for
+objects. See below for a description of these templates.
+.IP
+Parse_forms parses all forms in an fd file. It returns a dictionary of
+(ftmp, otmplist) tuples, indexed by formname.
+.IP
+Filename is the name of the forms definition file to inspect. The functions
+appends '.fd' if needed, and use 'sys.path' to locate the file.
+.IP
+formname is the name of the form to load. This argument is mandatory,
+even if the file only contains one form.
+.LP
+The form template and object template are structures that contain all
+the information read from the fd file, in 'natural' form. A form
+template record contains the following fields:
+.IP
+.nf
+"Name", the name of the form;
+"Width", the width of the form;
+"Height", the height of the form; and
+"Numberofobjects", the number of objects in the form.
+.LP
+An object template contains the following fields:
+.IP
+.nf
+"Class", the class of object (eg. FL.BUTTON);
+"Type", the sub-class (eg. FL.NORMALBUTTON);
+"Box", a list with four members: [x, y, width, height];
+"Boxtype", the type of box (eg. FL.DOWNBOX);
+"Colors", a list with the two object colors;
+"Alignment", the label alignment (eg. FL.ALIGNLEFT);
+"Style", the label style (eg. FL.BOLDSTYLE);
+"Lcol", the label color;
+"Label", a string containing the label;
+"Name", a string containing the name of the object;
+"Callback", a string containing the callback routine name; and
+"Argument", a string containing the callback routine extra argument.
+.SH
+Low-level create routines.
+.LP
+The three low-level creation routines are called as follows:
+.LP
+.ft C
+form = create_form(form_template)
+.IP
+Create an fl form from a form template. Returns the form created.
+.LP
+.ft C
+obj = create_object(form, obj_template)
+.IP
+Create an object in an fl form. Return the new object.
+An error is raised if the object has a callback routine.
+.SH
+High-level create routines.
+.LP
+The 'standard' way to handle forms in python is to define a class
+that contains the form and all the objects (insofar as they are named),
+and that defines all the callback functions, and use an instance of
+this class to handle the form interaction.
+Flp contains three routines that simplify handling this paradigm:
+.LP
+.ft C
+create_full_form(instance, ftuple)
+.IP
+This routine takes an instance of your form-handling class and an
+ftuple (as returned by the parsing routines) as parameters. It inserts
+the form into the instance, defines all object names and arranges that
+the callback methods are called. All the names inserted into the
+instance are the same as the names used for the objects, etc. in the
+fd file.
+.LP
+.ft C
+merge_full_form(instance, form, ftuple)
+.IP
+This function does the same as create_full_form, only it does not create
+the form itself nor the 'background box' that fdesign automatically
+adds to each form. This is useful if your class inherits a superclass
+that already defines a skeleton form (with 'OK' and 'Cancel' buttons,
+for instance), and you want to merge the new form into that existing
+form. The 'form' parameter is the form to which the new objects are
+added.
+.LP
+If you use the paradigm sketched here but need slightly more control
+over object creation there is a routine that creates a single object
+and inserts its name (and arranges for the callback routine to be
+called):
+.LP
+.ft C
+create_object_instance(instance, form, obj_template)
diff --git a/sys/lib/python/plat-irix5/flp.py b/sys/lib/python/plat-irix5/flp.py
new file mode 100755
index 000000000..4f9175f5f
--- /dev/null
+++ b/sys/lib/python/plat-irix5/flp.py
@@ -0,0 +1,451 @@
+#
+# flp - Module to load fl forms from fd files
+#
+# Jack Jansen, December 1991
+#
+import string
+import os
+import sys
+import FL
+
+SPLITLINE = '--------------------'
+FORMLINE = '=============== FORM ==============='
+ENDLINE = '=============================='
+
+class error(Exception):
+ pass
+
+##################################################################
+# Part 1 - The parsing routines #
+##################################################################
+
+#
+# Externally visible function. Load form.
+#
+def parse_form(filename, formname):
+ forms = checkcache(filename)
+ if forms is None:
+ forms = parse_forms(filename)
+ if forms.has_key(formname):
+ return forms[formname]
+ else:
+ raise error, 'No such form in fd file'
+
+#
+# Externally visible function. Load all forms.
+#
+def parse_forms(filename):
+ forms = checkcache(filename)
+ if forms is not None: return forms
+ fp = _open_formfile(filename)
+ nforms = _parse_fd_header(fp)
+ forms = {}
+ for i in range(nforms):
+ form = _parse_fd_form(fp, None)
+ forms[form[0].Name] = form
+ writecache(filename, forms)
+ return forms
+
+#
+# Internal: see if a cached version of the file exists
+#
+MAGIC = '.fdc'
+_internal_cache = {} # Used by frozen scripts only
+def checkcache(filename):
+ if _internal_cache.has_key(filename):
+ altforms = _internal_cache[filename]
+ return _unpack_cache(altforms)
+ import marshal
+ fp, filename = _open_formfile2(filename)
+ fp.close()
+ cachename = filename + 'c'
+ try:
+ fp = open(cachename, 'r')
+ except IOError:
+ #print 'flp: no cache file', cachename
+ return None
+ try:
+ if fp.read(4) != MAGIC:
+ print 'flp: bad magic word in cache file', cachename
+ return None
+ cache_mtime = rdlong(fp)
+ file_mtime = getmtime(filename)
+ if cache_mtime != file_mtime:
+ #print 'flp: outdated cache file', cachename
+ return None
+ #print 'flp: valid cache file', cachename
+ altforms = marshal.load(fp)
+ return _unpack_cache(altforms)
+ finally:
+ fp.close()
+
+def _unpack_cache(altforms):
+ forms = {}
+ for name in altforms.keys():
+ altobj, altlist = altforms[name]
+ obj = _newobj()
+ obj.make(altobj)
+ list = []
+ for altobj in altlist:
+ nobj = _newobj()
+ nobj.make(altobj)
+ list.append(nobj)
+ forms[name] = obj, list
+ return forms
+
+def rdlong(fp):
+ s = fp.read(4)
+ if len(s) != 4: return None
+ a, b, c, d = s[0], s[1], s[2], s[3]
+ return ord(a)<<24 | ord(b)<<16 | ord(c)<<8 | ord(d)
+
+def wrlong(fp, x):
+ a, b, c, d = (x>>24)&0xff, (x>>16)&0xff, (x>>8)&0xff, x&0xff
+ fp.write(chr(a) + chr(b) + chr(c) + chr(d))
+
+def getmtime(filename):
+ import os
+ from stat import ST_MTIME
+ try:
+ return os.stat(filename)[ST_MTIME]
+ except os.error:
+ return None
+
+#
+# Internal: write cached version of the form (parsing is too slow!)
+#
+def writecache(filename, forms):
+ import marshal
+ fp, filename = _open_formfile2(filename)
+ fp.close()
+ cachename = filename + 'c'
+ try:
+ fp = open(cachename, 'w')
+ except IOError:
+ print 'flp: can\'t create cache file', cachename
+ return # Never mind
+ fp.write('\0\0\0\0') # Seek back and write MAGIC when done
+ wrlong(fp, getmtime(filename))
+ altforms = _pack_cache(forms)
+ marshal.dump(altforms, fp)
+ fp.seek(0)
+ fp.write(MAGIC)
+ fp.close()
+ #print 'flp: wrote cache file', cachename
+
+#
+# External: print some statements that set up the internal cache.
+# This is for use with the "freeze" script. You should call
+# flp.freeze(filename) for all forms used by the script, and collect
+# the output on a file in a module file named "frozenforms.py". Then
+# in the main program of the script import frozenforms.
+# (Don't forget to take this out when using the unfrozen version of
+# the script!)
+#
+def freeze(filename):
+ forms = parse_forms(filename)
+ altforms = _pack_cache(forms)
+ print 'import flp'
+ print 'flp._internal_cache[', repr(filename), '] =', altforms
+
+#
+# Internal: create the data structure to be placed in the cache
+#
+def _pack_cache(forms):
+ altforms = {}
+ for name in forms.keys():
+ obj, list = forms[name]
+ altobj = obj.__dict__
+ altlist = []
+ for obj in list: altlist.append(obj.__dict__)
+ altforms[name] = altobj, altlist
+ return altforms
+
+#
+# Internal: Locate form file (using PYTHONPATH) and open file
+#
+def _open_formfile(filename):
+ return _open_formfile2(filename)[0]
+
+def _open_formfile2(filename):
+ if filename[-3:] != '.fd':
+ filename = filename + '.fd'
+ if filename[0] == '/':
+ try:
+ fp = open(filename,'r')
+ except IOError:
+ fp = None
+ else:
+ for pc in sys.path:
+ pn = os.path.join(pc, filename)
+ try:
+ fp = open(pn, 'r')
+ filename = pn
+ break
+ except IOError:
+ fp = None
+ if fp is None:
+ raise error, 'Cannot find forms file ' + filename
+ return fp, filename
+
+#
+# Internal: parse the fd file header, return number of forms
+#
+def _parse_fd_header(file):
+ # First read the magic header line
+ datum = _parse_1_line(file)
+ if datum != ('Magic', 12321):
+ raise error, 'Not a forms definition file'
+ # Now skip until we know number of forms
+ while 1:
+ datum = _parse_1_line(file)
+ if type(datum) == type(()) and datum[0] == 'Numberofforms':
+ break
+ return datum[1]
+#
+# Internal: parse fd form, or skip if name doesn't match.
+# the special value None means 'always parse it'.
+#
+def _parse_fd_form(file, name):
+ datum = _parse_1_line(file)
+ if datum != FORMLINE:
+ raise error, 'Missing === FORM === line'
+ form = _parse_object(file)
+ if form.Name == name or name is None:
+ objs = []
+ for j in range(form.Numberofobjects):
+ obj = _parse_object(file)
+ objs.append(obj)
+ return (form, objs)
+ else:
+ for j in range(form.Numberofobjects):
+ _skip_object(file)
+ return None
+
+#
+# Internal class: a convenient place to store object info fields
+#
+class _newobj:
+ def add(self, name, value):
+ self.__dict__[name] = value
+ def make(self, dict):
+ for name in dict.keys():
+ self.add(name, dict[name])
+
+#
+# Internal parsing routines.
+#
+def _parse_string(str):
+ if '\\' in str:
+ s = '\'' + str + '\''
+ try:
+ return eval(s)
+ except:
+ pass
+ return str
+
+def _parse_num(str):
+ return eval(str)
+
+def _parse_numlist(str):
+ slist = string.split(str)
+ nlist = []
+ for i in slist:
+ nlist.append(_parse_num(i))
+ return nlist
+
+# This dictionary maps item names to parsing routines.
+# If no routine is given '_parse_num' is default.
+_parse_func = { \
+ 'Name': _parse_string, \
+ 'Box': _parse_numlist, \
+ 'Colors': _parse_numlist, \
+ 'Label': _parse_string, \
+ 'Name': _parse_string, \
+ 'Callback': _parse_string, \
+ 'Argument': _parse_string }
+
+# This function parses a line, and returns either
+# a string or a tuple (name,value)
+
+import re
+prog = re.compile('^([^:]*): *(.*)')
+
+def _parse_line(line):
+ match = prog.match(line)
+ if not match:
+ return line
+ name, value = match.group(1, 2)
+ if name[0] == 'N':
+ name = string.join(string.split(name),'')
+ name = string.lower(name)
+ name = string.capitalize(name)
+ try:
+ pf = _parse_func[name]
+ except KeyError:
+ pf = _parse_num
+ value = pf(value)
+ return (name, value)
+
+def _readline(file):
+ line = file.readline()
+ if not line:
+ raise EOFError
+ return line[:-1]
+
+def _parse_1_line(file):
+ line = _readline(file)
+ while line == '':
+ line = _readline(file)
+ return _parse_line(line)
+
+def _skip_object(file):
+ line = ''
+ while not line in (SPLITLINE, FORMLINE, ENDLINE):
+ pos = file.tell()
+ line = _readline(file)
+ if line == FORMLINE:
+ file.seek(pos)
+
+def _parse_object(file):
+ obj = _newobj()
+ while 1:
+ pos = file.tell()
+ datum = _parse_1_line(file)
+ if datum in (SPLITLINE, FORMLINE, ENDLINE):
+ if datum == FORMLINE:
+ file.seek(pos)
+ return obj
+ if type(datum) is not type(()) or len(datum) != 2:
+ raise error, 'Parse error, illegal line in object: '+datum
+ obj.add(datum[0], datum[1])
+
+#################################################################
+# Part 2 - High-level object/form creation routines #
+#################################################################
+
+#
+# External - Create a form an link to an instance variable.
+#
+def create_full_form(inst, (fdata, odatalist)):
+ form = create_form(fdata)
+ exec 'inst.'+fdata.Name+' = form\n'
+ for odata in odatalist:
+ create_object_instance(inst, form, odata)
+
+#
+# External - Merge a form into an existing form in an instance
+# variable.
+#
+def merge_full_form(inst, form, (fdata, odatalist)):
+ exec 'inst.'+fdata.Name+' = form\n'
+ if odatalist[0].Class != FL.BOX:
+ raise error, 'merge_full_form() expects FL.BOX as first obj'
+ for odata in odatalist[1:]:
+ create_object_instance(inst, form, odata)
+
+
+#################################################################
+# Part 3 - Low-level object/form creation routines #
+#################################################################
+
+#
+# External Create_form - Create form from parameters
+#
+def create_form(fdata):
+ import fl
+ return fl.make_form(FL.NO_BOX, fdata.Width, fdata.Height)
+
+#
+# External create_object - Create an object. Make sure there are
+# no callbacks. Returns the object created.
+#
+def create_object(form, odata):
+ obj = _create_object(form, odata)
+ if odata.Callback:
+ raise error, 'Creating free object with callback'
+ return obj
+#
+# External create_object_instance - Create object in an instance.
+#
+def create_object_instance(inst, form, odata):
+ obj = _create_object(form, odata)
+ if odata.Callback:
+ cbfunc = eval('inst.'+odata.Callback)
+ obj.set_call_back(cbfunc, odata.Argument)
+ if odata.Name:
+ exec 'inst.' + odata.Name + ' = obj\n'
+#
+# Internal _create_object: Create the object and fill options
+#
+def _create_object(form, odata):
+ crfunc = _select_crfunc(form, odata.Class)
+ obj = crfunc(odata.Type, odata.Box[0], odata.Box[1], odata.Box[2], \
+ odata.Box[3], odata.Label)
+ if not odata.Class in (FL.BEGIN_GROUP, FL.END_GROUP):
+ obj.boxtype = odata.Boxtype
+ obj.col1 = odata.Colors[0]
+ obj.col2 = odata.Colors[1]
+ obj.align = odata.Alignment
+ obj.lstyle = odata.Style
+ obj.lsize = odata.Size
+ obj.lcol = odata.Lcol
+ return obj
+#
+# Internal crfunc: helper function that returns correct create function
+#
+def _select_crfunc(fm, cl):
+ if cl == FL.BEGIN_GROUP: return fm.bgn_group
+ elif cl == FL.END_GROUP: return fm.end_group
+ elif cl == FL.BITMAP: return fm.add_bitmap
+ elif cl == FL.BOX: return fm.add_box
+ elif cl == FL.BROWSER: return fm.add_browser
+ elif cl == FL.BUTTON: return fm.add_button
+ elif cl == FL.CHART: return fm.add_chart
+ elif cl == FL.CHOICE: return fm.add_choice
+ elif cl == FL.CLOCK: return fm.add_clock
+ elif cl == FL.COUNTER: return fm.add_counter
+ elif cl == FL.DIAL: return fm.add_dial
+ elif cl == FL.FREE: return fm.add_free
+ elif cl == FL.INPUT: return fm.add_input
+ elif cl == FL.LIGHTBUTTON: return fm.add_lightbutton
+ elif cl == FL.MENU: return fm.add_menu
+ elif cl == FL.POSITIONER: return fm.add_positioner
+ elif cl == FL.ROUNDBUTTON: return fm.add_roundbutton
+ elif cl == FL.SLIDER: return fm.add_slider
+ elif cl == FL.VALSLIDER: return fm.add_valslider
+ elif cl == FL.TEXT: return fm.add_text
+ elif cl == FL.TIMER: return fm.add_timer
+ else:
+ raise error, 'Unknown object type: %r' % (cl,)
+
+
+def test():
+ import time
+ t0 = time.time()
+ if len(sys.argv) == 2:
+ forms = parse_forms(sys.argv[1])
+ t1 = time.time()
+ print 'parse time:', 0.001*(t1-t0), 'sec.'
+ keys = forms.keys()
+ keys.sort()
+ for i in keys:
+ _printform(forms[i])
+ elif len(sys.argv) == 3:
+ form = parse_form(sys.argv[1], sys.argv[2])
+ t1 = time.time()
+ print 'parse time:', round(t1-t0, 3), 'sec.'
+ _printform(form)
+ else:
+ print 'Usage: test fdfile [form]'
+
+def _printform(form):
+ f = form[0]
+ objs = form[1]
+ print 'Form ', f.Name, ', size: ', f.Width, f.Height, ' Nobj ', f.Numberofobjects
+ for i in objs:
+ print ' Obj ', i.Name, ' type ', i.Class, i.Type
+ print ' Box ', i.Box, ' btype ', i.Boxtype
+ print ' Label ', i.Label, ' size/style/col/align ', i.Size,i.Style, i.Lcol, i.Alignment
+ print ' cols ', i.Colors
+ print ' cback ', i.Callback, i.Argument
diff --git a/sys/lib/python/plat-irix5/jpeg.py b/sys/lib/python/plat-irix5/jpeg.py
new file mode 100755
index 000000000..f8fc7e721
--- /dev/null
+++ b/sys/lib/python/plat-irix5/jpeg.py
@@ -0,0 +1,111 @@
+# 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.
+
+class error(Exception):
+ pass
+
+options = {'quality': 75, 'optimize': 0, 'smooth': 0, 'forcegray': 0}
+
+comp = None
+decomp = None
+
+def compress(imgdata, width, height, bytesperpixel):
+ global comp
+ import 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
+ 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) is not 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)
diff --git a/sys/lib/python/plat-irix5/panel.py b/sys/lib/python/plat-irix5/panel.py
new file mode 100755
index 000000000..12e62a51b
--- /dev/null
+++ b/sys/lib/python/plat-irix5/panel.py
@@ -0,0 +1,281 @@
+# Module 'panel'
+#
+# Support for the Panel library.
+# Uses built-in module 'pnl'.
+# Applications should use 'panel.function' instead of 'pnl.function';
+# most 'pnl' functions are transparently exported by 'panel',
+# but dopanel() is overridden and you have to use this version
+# if you want to use callbacks.
+
+
+import pnl
+
+
+debug = 0
+
+
+# Test if an object is a list.
+#
+def is_list(x):
+ return type(x) == type([])
+
+
+# Reverse a list.
+#
+def reverse(list):
+ res = []
+ for item in list:
+ res.insert(0, item)
+ return res
+
+
+# Get an attribute of a list, which may itself be another list.
+# Don't use 'prop' for name.
+#
+def getattrlist(list, name):
+ for item in list:
+ if item and is_list(item) and item[0] == name:
+ return item[1:]
+ return []
+
+
+# Get a property of a list, which may itself be another list.
+#
+def getproplist(list, name):
+ for item in list:
+ if item and is_list(item) and item[0] == 'prop':
+ if len(item) > 1 and item[1] == name:
+ return item[2:]
+ return []
+
+
+# Test if an actuator description contains the property 'end-of-group'
+#
+def is_endgroup(list):
+ x = getproplist(list, 'end-of-group')
+ return (x and x[0] == '#t')
+
+
+# Neatly display an actuator definition given as S-expression
+# the prefix string is printed before each line.
+#
+def show_actuator(prefix, a):
+ for item in a:
+ if not is_list(item):
+ print prefix, item
+ elif item and item[0] == 'al':
+ print prefix, 'Subactuator list:'
+ for a in item[1:]:
+ show_actuator(prefix + ' ', a)
+ elif len(item) == 2:
+ print prefix, item[0], '=>', item[1]
+ elif len(item) == 3 and item[0] == 'prop':
+ print prefix, 'Prop', item[1], '=>',
+ print item[2]
+ else:
+ print prefix, '?', item
+
+
+# Neatly display a panel.
+#
+def show_panel(prefix, p):
+ for item in p:
+ if not is_list(item):
+ print prefix, item
+ elif item and item[0] == 'al':
+ print prefix, 'Actuator list:'
+ for a in item[1:]:
+ show_actuator(prefix + ' ', a)
+ elif len(item) == 2:
+ print prefix, item[0], '=>', item[1]
+ elif len(item) == 3 and item[0] == 'prop':
+ print prefix, 'Prop', item[1], '=>',
+ print item[2]
+ else:
+ print prefix, '?', item
+
+
+# Exception raised by build_actuator or build_panel.
+#
+panel_error = 'panel error'
+
+
+# Dummy callback used to initialize the callbacks.
+#
+def dummy_callback(arg):
+ pass
+
+
+# Assign attributes to members of the target.
+# Attribute names in exclist are ignored.
+# The member name is the attribute name prefixed with the prefix.
+#
+def assign_members(target, attrlist, exclist, prefix):
+ for item in attrlist:
+ if is_list(item) and len(item) == 2 and item[0] not in exclist:
+ name, value = item[0], item[1]
+ ok = 1
+ if value[0] in '-0123456789':
+ value = eval(value)
+ elif value[0] == '"':
+ value = value[1:-1]
+ elif value == 'move-then-resize':
+ # Strange default set by Panel Editor...
+ ok = 0
+ else:
+ print 'unknown value', value, 'for', name
+ ok = 0
+ if ok:
+ lhs = 'target.' + prefix + name
+ stmt = lhs + '=' + repr(value)
+ if debug: print 'exec', stmt
+ try:
+ exec stmt + '\n'
+ except KeyboardInterrupt: # Don't catch this!
+ raise KeyboardInterrupt
+ except:
+ print 'assign failed:', stmt
+
+
+# Build a real actuator from an actuator description.
+# Return a pair (actuator, name).
+#
+def build_actuator(descr):
+ namelist = getattrlist(descr, 'name')
+ if namelist:
+ # Assume it is a string
+ actuatorname = namelist[0][1:-1]
+ else:
+ actuatorname = ''
+ type = descr[0]
+ if type[:4] == 'pnl_': type = type[4:]
+ act = pnl.mkact(type)
+ act.downfunc = act.activefunc = act.upfunc = dummy_callback
+ #
+ assign_members(act, descr[1:], ['al', 'data', 'name'], '')
+ #
+ # Treat actuator-specific data
+ #
+ datalist = getattrlist(descr, 'data')
+ prefix = ''
+ if type[-4:] == 'puck':
+ prefix = 'puck_'
+ elif type == 'mouse':
+ prefix = 'mouse_'
+ assign_members(act, datalist, [], prefix)
+ #
+ return act, actuatorname
+
+
+# Build all sub-actuators and add them to the super-actuator.
+# The super-actuator must already have been added to the panel.
+# Sub-actuators with defined names are added as members to the panel
+# so they can be referenced as p.name.
+#
+# Note: I have no idea how panel.endgroup() works when applied
+# to a sub-actuator.
+#
+def build_subactuators(panel, super_act, al):
+ #
+ # This is nearly the same loop as below in build_panel(),
+ # except a call is made to addsubact() instead of addact().
+ #
+ for a in al:
+ act, name = build_actuator(a)
+ act.addsubact(super_act)
+ if name:
+ stmt = 'panel.' + name + ' = act'
+ if debug: print 'exec', stmt
+ exec stmt + '\n'
+ if is_endgroup(a):
+ panel.endgroup()
+ sub_al = getattrlist(a, 'al')
+ if sub_al:
+ build_subactuators(panel, act, sub_al)
+ #
+ # Fix the actuator to which whe just added subactuators.
+ # This can't hurt (I hope) and is needed for the scroll actuator.
+ #
+ super_act.fixact()
+
+
+# Build a real panel from a panel definition.
+# Return a panel object p, where for each named actuator a, p.name is a
+# reference to a.
+#
+def build_panel(descr):
+ #
+ # Sanity check
+ #
+ if (not descr) or descr[0] != 'panel':
+ raise panel_error, 'panel description must start with "panel"'
+ #
+ if debug: show_panel('', descr)
+ #
+ # Create an empty panel
+ #
+ panel = pnl.mkpanel()
+ #
+ # Assign panel attributes
+ #
+ assign_members(panel, descr[1:], ['al'], '')
+ #
+ # Look for actuator list
+ #
+ al = getattrlist(descr, 'al')
+ #
+ # The order in which actuators are created is important
+ # because of the endgroup() operator.
+ # Unfortunately the Panel Editor outputs the actuator list
+ # in reverse order, so we reverse it here.
+ #
+ al = reverse(al)
+ #
+ for a in al:
+ act, name = build_actuator(a)
+ act.addact(panel)
+ if name:
+ stmt = 'panel.' + name + ' = act'
+ exec stmt + '\n'
+ if is_endgroup(a):
+ panel.endgroup()
+ sub_al = getattrlist(a, 'al')
+ if sub_al:
+ build_subactuators(panel, act, sub_al)
+ #
+ return panel
+
+
+# Wrapper around pnl.dopanel() which calls call-back functions.
+#
+def my_dopanel():
+ # Extract only the first 4 elements to allow for future expansion
+ a, down, active, up = pnl.dopanel()[:4]
+ if down:
+ down.downfunc(down)
+ if active:
+ active.activefunc(active)
+ if up:
+ up.upfunc(up)
+ return a
+
+
+# Create one or more panels from a description file (S-expressions)
+# generated by the Panel Editor.
+#
+def defpanellist(file):
+ import panelparser
+ descrlist = panelparser.parse_file(open(file, 'r'))
+ panellist = []
+ for descr in descrlist:
+ panellist.append(build_panel(descr))
+ return panellist
+
+
+# Import everything from built-in method pnl, so the user can always
+# use panel.foo() instead of pnl.foo().
+# This gives *no* performance penalty once this module is imported.
+#
+from pnl import * # for export
+
+dopanel = my_dopanel # override pnl.dopanel
diff --git a/sys/lib/python/plat-irix5/panelparser.py b/sys/lib/python/plat-irix5/panelparser.py
new file mode 100755
index 000000000..c831c4927
--- /dev/null
+++ b/sys/lib/python/plat-irix5/panelparser.py
@@ -0,0 +1,128 @@
+# Module 'parser'
+#
+# Parse S-expressions output by the Panel Editor
+# (which is written in Scheme so it can't help writing S-expressions).
+#
+# See notes at end of file.
+
+
+whitespace = ' \t\n'
+operators = '()\''
+separators = operators + whitespace + ';' + '"'
+
+
+# Tokenize a string.
+# Return a list of tokens (strings).
+#
+def tokenize_string(s):
+ tokens = []
+ while s:
+ c = s[:1]
+ if c in whitespace:
+ s = s[1:]
+ elif c == ';':
+ s = ''
+ elif c == '"':
+ n = len(s)
+ i = 1
+ while i < n:
+ c = s[i]
+ i = i+1
+ if c == '"': break
+ if c == '\\': i = i+1
+ tokens.append(s[:i])
+ s = s[i:]
+ elif c in operators:
+ tokens.append(c)
+ s = s[1:]
+ else:
+ n = len(s)
+ i = 1
+ while i < n:
+ if s[i] in separators: break
+ i = i+1
+ tokens.append(s[:i])
+ s = s[i:]
+ return tokens
+
+
+# Tokenize a whole file (given as file object, not as file name).
+# Return a list of tokens (strings).
+#
+def tokenize_file(fp):
+ tokens = []
+ while 1:
+ line = fp.readline()
+ if not line: break
+ tokens = tokens + tokenize_string(line)
+ return tokens
+
+
+# Exception raised by parse_exr.
+#
+syntax_error = 'syntax error'
+
+
+# Parse an S-expression.
+# Input is a list of tokens as returned by tokenize_*().
+# Return a pair (expr, tokens)
+# where expr is a list representing the s-expression,
+# and tokens contains the remaining tokens.
+# May raise syntax_error.
+#
+def parse_expr(tokens):
+ if (not tokens) or tokens[0] != '(':
+ raise syntax_error, 'expected "("'
+ tokens = tokens[1:]
+ expr = []
+ while 1:
+ if not tokens:
+ raise syntax_error, 'missing ")"'
+ if tokens[0] == ')':
+ return expr, tokens[1:]
+ elif tokens[0] == '(':
+ subexpr, tokens = parse_expr(tokens)
+ expr.append(subexpr)
+ else:
+ expr.append(tokens[0])
+ tokens = tokens[1:]
+
+
+# Parse a file (given as file object, not as file name).
+# Return a list of parsed S-expressions found at the top level.
+#
+def parse_file(fp):
+ tokens = tokenize_file(fp)
+ exprlist = []
+ while tokens:
+ expr, tokens = parse_expr(tokens)
+ exprlist.append(expr)
+ return exprlist
+
+
+# EXAMPLE:
+#
+# The input
+# '(hip (hop hur-ray))'
+#
+# passed to tokenize_string() returns the token list
+# ['(', 'hip', '(', 'hop', 'hur-ray', ')', ')']
+#
+# When this is passed to parse_expr() it returns the expression
+# ['hip', ['hop', 'hur-ray']]
+# plus an empty token list (because there are no tokens left.
+#
+# When a file containing the example is passed to parse_file() it returns
+# a list whose only element is the output of parse_expr() above:
+# [['hip', ['hop', 'hur-ray']]]
+
+
+# TOKENIZING:
+#
+# Comments start with semicolon (;) and continue till the end of the line.
+#
+# Tokens are separated by whitespace, except the following characters
+# always form a separate token (outside strings):
+# ( ) '
+# Strings are enclosed in double quotes (") and backslash (\) is used
+# as escape character in strings.
diff --git a/sys/lib/python/plat-irix5/readcd.doc b/sys/lib/python/plat-irix5/readcd.doc
new file mode 100755
index 000000000..1be549c79
--- /dev/null
+++ b/sys/lib/python/plat-irix5/readcd.doc
@@ -0,0 +1,104 @@
+Interface to CD-ROM player.
+
+This module implements an interface to the built-in cd module. The
+intention is to provide a more user-friendly interface than the
+built-in module.
+
+The module defines a class Readcd with several methods. The
+initialization of the class will try to open the CD player. This
+means that initialization will fail if the CD player is already in
+use. A RuntimeError will be raised by the cd module in that case.
+
+The way to work with this module is as follows. The user specifies
+the parts of the CD that are to be read and he specifies callback
+functions which are to be called by the system. At some point he can
+tell the system to play. The specified parts of the CD will then be
+read and the callbacks will be called.
+
+Initialization.
+===============
+
+r = readcd.Readcd([cd-player [, mode]])
+
+The optional arguments are the name of the CD device and the mode.
+When "mode" is not specified, it defaults to 'r' (which is the only
+possible value); when "cd-player" also isn't specified, it defaults
+to "None" which indicates the default CD player.
+
+Methods.
+========
+
+eject() -- Eject the CD from the player.
+
+reset() -- Reset the list of data stretches to be played.
+
+appendtrack(track) -- Append the specified track to the list of music
+stretches.
+
+appendstretch(first, last) -- Append the stretch from "first" to "last"
+to the list of music stretches. Both "first" and "last" can be in one
+of four forms. "None": for "first", the beginning of the CD, for
+"last" the end of the CD; a single integer: a track number--playing
+starts at the beginning of the track or ends at the end of the
+specified track; a three-tuple: the absolute time from the start of
+the CD in minutes, seconds, frames; a four-tuple: track number and
+relative time within the track in minutes, seconds, frames.
+
+settracks(tracklist) -- The argument is a list of integers. The list
+of stretches is set to argument list. The old list is discarded.
+
+setcallback(type, func, arg) -- Set a callback function for "type".
+The function will be called as func(arg, type, data) where "arg" is
+the third argument of setcallback, "type" is the type of callback,
+"data" is type-dependent data. See the CDsetcallback(3) manual page
+for more information. The possible "type" arguments are defined in
+the CD module.
+
+removecallback(type) -- Remove the callback for "type".
+
+gettrackinfo([tracklist]) -- Return a list of tuples. Each tuple
+consists of start and length information of a track. The start and
+length information consist of three-tuples with minutes, seconds and
+frames. The optional tracklist argument gives a list of interesting
+track numbers. If no tracklist is specified, information about all
+tracks is returned.
+
+getstatus() -- Return the status information of the CD.
+
+play() -- Play the preprogrammed stretches of music from the CD. When
+nothing was programmed, the whole CD is played.
+
+Specifying stretches.
+=====================
+
+There are three methods available to specify a stretch of music to be
+played. The easiest way is to use "settracklist(tracklist)" with which
+a list of tracks can be specified. "settracklist(tracklist)" is
+equivalent to the sequence
+ reset()
+ for track in tracklist:
+ appendtrack(track)
+
+The next method is "appendtrack(track)" with which a whole track can be
+added to the list of music to be played. "appendtrack(track)" is
+equivalent to "appendstretch(track, track)".
+
+The most complete method is "appendstretch(first, last)". Using this
+method, it is possible to specify any stretch of music.
+
+When two consecutive tracks are played, it is possible to choose
+whether the pause that may be between the tracks is played as well or
+whether the pause should be skipped. When the end of a stretch is
+specified using a track number and the next stretch starts at the
+beginning of the following track and that was also specified using the
+track number (that is, both were specified as integers, not as tuples),
+the pause is played. When either value was specified using absolute
+time or track-relative time (that is, as three-tuple or as
+four-tuple), the pause will not be played.
+
+Errors.
+=======
+
+When an error occurs, an exception will be raised. Depending on where
+the error occurs, the exception may either be "readcd.Error" or
+"RuntimeError".
diff --git a/sys/lib/python/plat-irix5/readcd.py b/sys/lib/python/plat-irix5/readcd.py
new file mode 100755
index 000000000..5453ce421
--- /dev/null
+++ b/sys/lib/python/plat-irix5/readcd.py
@@ -0,0 +1,244 @@
+# Class interface to the CD module.
+
+import cd, CD
+
+class Error(Exception):
+ pass
+class _Stop(Exception):
+ pass
+
+def _doatime(self, cb_type, data):
+ if ((data[0] * 60) + data[1]) * 75 + data[2] > self.end:
+## print 'done with list entry', repr(self.listindex)
+ raise _Stop
+ func, arg = self.callbacks[cb_type]
+ if func:
+ func(arg, cb_type, data)
+
+def _dopnum(self, cb_type, data):
+ if data > self.end:
+## print 'done with list entry', repr(self.listindex)
+ raise _Stop
+ func, arg = self.callbacks[cb_type]
+ if func:
+ func(arg, cb_type, data)
+
+class Readcd:
+ def __init__(self, *arg):
+ if len(arg) == 0:
+ self.player = cd.open()
+ elif len(arg) == 1:
+ self.player = cd.open(arg[0])
+ elif len(arg) == 2:
+ self.player = cd.open(arg[0], arg[1])
+ else:
+ raise Error, 'bad __init__ call'
+ self.list = []
+ self.callbacks = [(None, None)] * 8
+ self.parser = cd.createparser()
+ self.playing = 0
+ self.end = 0
+ self.status = None
+ self.trackinfo = None
+
+ def eject(self):
+ self.player.eject()
+ self.list = []
+ self.end = 0
+ self.listindex = 0
+ self.status = None
+ self.trackinfo = None
+ if self.playing:
+## print 'stop playing from eject'
+ raise _Stop
+
+ def pmsf2msf(self, track, min, sec, frame):
+ if not self.status:
+ self.cachestatus()
+ if track < self.status[5] or track > self.status[6]:
+ raise Error, 'track number out of range'
+ if not self.trackinfo:
+ self.cacheinfo()
+ start, total = self.trackinfo[track]
+ start = ((start[0] * 60) + start[1]) * 75 + start[2]
+ total = ((total[0] * 60) + total[1]) * 75 + total[2]
+ block = ((min * 60) + sec) * 75 + frame
+ if block > total:
+ raise Error, 'out of range'
+ block = start + block
+ min, block = divmod(block, 75*60)
+ sec, frame = divmod(block, 75)
+ return min, sec, frame
+
+ def reset(self):
+ self.list = []
+
+ def appendtrack(self, track):
+ self.appendstretch(track, track)
+
+ def appendstretch(self, start, end):
+ if not self.status:
+ self.cachestatus()
+ if not start:
+ start = 1
+ if not end:
+ end = self.status[6]
+ if type(end) == type(0):
+ if end < self.status[5] or end > self.status[6]:
+ raise Error, 'range error'
+ else:
+ l = len(end)
+ if l == 4:
+ prog, min, sec, frame = end
+ if prog < self.status[5] or prog > self.status[6]:
+ raise Error, 'range error'
+ end = self.pmsf2msf(prog, min, sec, frame)
+ elif l != 3:
+ raise Error, 'syntax error'
+ if type(start) == type(0):
+ if start < self.status[5] or start > self.status[6]:
+ raise Error, 'range error'
+ if len(self.list) > 0:
+ s, e = self.list[-1]
+ if type(e) == type(0):
+ if start == e+1:
+ start = s
+ del self.list[-1]
+ else:
+ l = len(start)
+ if l == 4:
+ prog, min, sec, frame = start
+ if prog < self.status[5] or prog > self.status[6]:
+ raise Error, 'range error'
+ start = self.pmsf2msf(prog, min, sec, frame)
+ elif l != 3:
+ raise Error, 'syntax error'
+ self.list.append((start, end))
+
+ def settracks(self, list):
+ self.list = []
+ for track in list:
+ self.appendtrack(track)
+
+ def setcallback(self, cb_type, func, arg):
+ if cb_type < 0 or cb_type >= 8:
+ raise Error, 'type out of range'
+ self.callbacks[cb_type] = (func, arg)
+ if self.playing:
+ start, end = self.list[self.listindex]
+ if type(end) == type(0):
+ if cb_type != CD.PNUM:
+ self.parser.setcallback(cb_type, func, arg)
+ else:
+ if cb_type != CD.ATIME:
+ self.parser.setcallback(cb_type, func, arg)
+
+ def removecallback(self, cb_type):
+ if cb_type < 0 or cb_type >= 8:
+ raise Error, 'type out of range'
+ self.callbacks[cb_type] = (None, None)
+ if self.playing:
+ start, end = self.list[self.listindex]
+ if type(end) == type(0):
+ if cb_type != CD.PNUM:
+ self.parser.removecallback(cb_type)
+ else:
+ if cb_type != CD.ATIME:
+ self.parser.removecallback(cb_type)
+
+ def gettrackinfo(self, *arg):
+ if not self.status:
+ self.cachestatus()
+ if not self.trackinfo:
+ self.cacheinfo()
+ if len(arg) == 0:
+ return self.trackinfo[self.status[5]:self.status[6]+1]
+ result = []
+ for i in arg:
+ if i < self.status[5] or i > self.status[6]:
+ raise Error, 'range error'
+ result.append(self.trackinfo[i])
+ return result
+
+ def cacheinfo(self):
+ if not self.status:
+ self.cachestatus()
+ self.trackinfo = []
+ for i in range(self.status[5]):
+ self.trackinfo.append(None)
+ for i in range(self.status[5], self.status[6]+1):
+ self.trackinfo.append(self.player.gettrackinfo(i))
+
+ def cachestatus(self):
+ self.status = self.player.getstatus()
+ if self.status[0] == CD.NODISC:
+ self.status = None
+ raise Error, 'no disc in player'
+
+ def getstatus(self):
+ return self.player.getstatus()
+
+ def play(self):
+ if not self.status:
+ self.cachestatus()
+ size = self.player.bestreadsize()
+ self.listindex = 0
+ self.playing = 0
+ for i in range(8):
+ func, arg = self.callbacks[i]
+ if func:
+ self.parser.setcallback(i, func, arg)
+ else:
+ self.parser.removecallback(i)
+ if len(self.list) == 0:
+ for i in range(self.status[5], self.status[6]+1):
+ self.appendtrack(i)
+ try:
+ while 1:
+ if not self.playing:
+ if self.listindex >= len(self.list):
+ return
+ start, end = self.list[self.listindex]
+ if type(start) == type(0):
+ dummy = self.player.seektrack(
+ start)
+ else:
+ min, sec, frame = start
+ dummy = self.player.seek(
+ min, sec, frame)
+ if type(end) == type(0):
+ self.parser.setcallback(
+ CD.PNUM, _dopnum, self)
+ self.end = end
+ func, arg = \
+ self.callbacks[CD.ATIME]
+ if func:
+ self.parser.setcallback(CD.ATIME, func, arg)
+ else:
+ self.parser.removecallback(CD.ATIME)
+ else:
+ min, sec, frame = end
+ self.parser.setcallback(
+ CD.ATIME, _doatime,
+ self)
+ self.end = (min * 60 + sec) * \
+ 75 + frame
+ func, arg = \
+ self.callbacks[CD.PNUM]
+ if func:
+ self.parser.setcallback(CD.PNUM, func, arg)
+ else:
+ self.parser.removecallback(CD.PNUM)
+ self.playing = 1
+ data = self.player.readda(size)
+ if data == '':
+ self.playing = 0
+ self.listindex = self.listindex + 1
+ continue
+ try:
+ self.parser.parseframe(data)
+ except _Stop:
+ self.playing = 0
+ self.listindex = self.listindex + 1
+ finally:
+ self.playing = 0
diff --git a/sys/lib/python/plat-irix5/regen b/sys/lib/python/plat-irix5/regen
new file mode 100755
index 000000000..c950a475c
--- /dev/null
+++ b/sys/lib/python/plat-irix5/regen
@@ -0,0 +1,10 @@
+#! /bin/sh
+case `uname -sr` in
+'IRIX '[45].*) ;;
+*) echo Probably not on an IRIX system 1>&2
+ exit 1;;
+esac
+set -v
+h2py /usr/include/sys/file.h
+h2py -i '(u_long)' /usr/include/netinet/in.h
+h2py /usr/include/errno.h
diff --git a/sys/lib/python/plat-irix5/torgb.py b/sys/lib/python/plat-irix5/torgb.py
new file mode 100755
index 000000000..54c86c477
--- /dev/null
+++ b/sys/lib/python/plat-irix5/torgb.py
@@ -0,0 +1,99 @@
+# Convert "arbitrary" image files to rgb files (SGI's image format).
+# Input may be compressed.
+# The uncompressed file type may be PBM, PGM, PPM, GIF, TIFF, or Sun raster.
+# An exception is raised if the file is not of a recognized type.
+# Returned filename is either the input filename or a temporary filename;
+# in the latter case the caller must ensure that it is removed.
+# Other temporary files used are removed by the function.
+
+import os
+import tempfile
+import pipes
+import imghdr
+
+table = {}
+
+t = pipes.Template()
+t.append('fromppm $IN $OUT', 'ff')
+table['ppm'] = t
+
+t = pipes.Template()
+t.append('(PATH=$PATH:/ufs/guido/bin/sgi; exec pnmtoppm)', '--')
+t.append('fromppm $IN $OUT', 'ff')
+table['pnm'] = t
+table['pgm'] = t
+table['pbm'] = t
+
+t = pipes.Template()
+t.append('fromgif $IN $OUT', 'ff')
+table['gif'] = t
+
+t = pipes.Template()
+t.append('tifftopnm', '--')
+t.append('(PATH=$PATH:/ufs/guido/bin/sgi; exec pnmtoppm)', '--')
+t.append('fromppm $IN $OUT', 'ff')
+table['tiff'] = t
+
+t = pipes.Template()
+t.append('rasttopnm', '--')
+t.append('(PATH=$PATH:/ufs/guido/bin/sgi; exec pnmtoppm)', '--')
+t.append('fromppm $IN $OUT', 'ff')
+table['rast'] = t
+
+t = pipes.Template()
+t.append('djpeg', '--')
+t.append('(PATH=$PATH:/ufs/guido/bin/sgi; exec pnmtoppm)', '--')
+t.append('fromppm $IN $OUT', 'ff')
+table['jpeg'] = t
+
+uncompress = pipes.Template()
+uncompress.append('uncompress', '--')
+
+
+class error(Exception):
+ pass
+
+def torgb(filename):
+ temps = []
+ ret = None
+ try:
+ ret = _torgb(filename, temps)
+ finally:
+ for temp in temps[:]:
+ if temp != ret:
+ try:
+ os.unlink(temp)
+ except os.error:
+ pass
+ temps.remove(temp)
+ return ret
+
+def _torgb(filename, temps):
+ if filename[-2:] == '.Z':
+ (fd, fname) = tempfile.mkstemp()
+ os.close(fd)
+ temps.append(fname)
+ sts = uncompress.copy(filename, fname)
+ if sts:
+ raise error, filename + ': uncompress failed'
+ else:
+ fname = filename
+ try:
+ ftype = imghdr.what(fname)
+ except IOError, msg:
+ if type(msg) == type(()) and len(msg) == 2 and \
+ type(msg[0]) == type(0) and type(msg[1]) == type(''):
+ msg = msg[1]
+ if type(msg) is not type(''):
+ msg = repr(msg)
+ raise error, filename + ': ' + msg
+ if ftype == 'rgb':
+ return fname
+ if ftype is None or not table.has_key(ftype):
+ raise error, '%s: unsupported image file type %r' % (filename, ftype)
+ (fd, temp) = tempfile.mkstemp()
+ os.close(fd)
+ sts = table[ftype].copy(fname, temp)
+ if sts:
+ raise error, filename + ': conversion to rgb failed'
+ return temp