[xiph-commits] r10510 - in experimental/j: . Elphel333 Elphel333/common Elphel333/http Elphel333/http/config_cgi Elphel333/rtp Elphel333/rtp/cgi Elphel333/rtp/daemon Elphel333/rtp/daemon/rtp Elphel333/rtp/daemon/rtp/win32 Elphel333/shout

j at svn.xiph.org j at svn.xiph.org
Wed Nov 30 17:40:38 PST 2005


Author: j
Date: 2005-11-30 17:39:59 -0800 (Wed, 30 Nov 2005)
New Revision: 10510

Added:
   experimental/j/Elphel333/
   experimental/j/Elphel333/README
   experimental/j/Elphel333/common/
   experimental/j/Elphel333/common/.target-makefrag
   experimental/j/Elphel333/common/Makefile
   experimental/j/Elphel333/common/c313a.h
   experimental/j/Elphel333/common/defines.h
   experimental/j/Elphel333/common/oggtheora.c
   experimental/j/Elphel333/common/oggtheora.h
   experimental/j/Elphel333/common/oggtheora_tables.h
   experimental/j/Elphel333/common/utils.c
   experimental/j/Elphel333/http/
   experimental/j/Elphel333/http/.target-makefrag
   experimental/j/Elphel333/http/Makefile
   experimental/j/Elphel333/http/README
   experimental/j/Elphel333/http/TheoraHTTP.c
   experimental/j/Elphel333/http/config_cgi/
   experimental/j/Elphel333/http/config_cgi/.target-makefrag
   experimental/j/Elphel333/http/config_cgi/Makefile
   experimental/j/Elphel333/http/config_cgi/http_strm.c
   experimental/j/Elphel333/http/config_cgi/index1.html
   experimental/j/Elphel333/rtp/
   experimental/j/Elphel333/rtp/README
   experimental/j/Elphel333/rtp/cgi/
   experimental/j/Elphel333/rtp/cgi/.target-makefrag
   experimental/j/Elphel333/rtp/cgi/Makefile
   experimental/j/Elphel333/rtp/cgi/cstrm.c
   experimental/j/Elphel333/rtp/cgi/defines.h
   experimental/j/Elphel333/rtp/cgi/index1.html
   experimental/j/Elphel333/rtp/daemon/
   experimental/j/Elphel333/rtp/daemon/.target-makefrag
   experimental/j/Elphel333/rtp/daemon/Makefile
   experimental/j/Elphel333/rtp/daemon/README
   experimental/j/Elphel333/rtp/daemon/TheoraStrm.c
   experimental/j/Elphel333/rtp/daemon/rtp/
   experimental/j/Elphel333/rtp/daemon/rtp/.target-makefrag
   experimental/j/Elphel333/rtp/daemon/rtp/COPYRIGHT
   experimental/j/Elphel333/rtp/daemon/rtp/MODS
   experimental/j/Elphel333/rtp/daemon/rtp/Makefile.am
   experimental/j/Elphel333/rtp/daemon/rtp/Makefile.in
   experimental/j/Elphel333/rtp/daemon/rtp/README
   experimental/j/Elphel333/rtp/daemon/rtp/README.qfdes
   experimental/j/Elphel333/rtp/daemon/rtp/VERSION
   experimental/j/Elphel333/rtp/daemon/rtp/acconfig.h
   experimental/j/Elphel333/rtp/daemon/rtp/aclocal.m4
   experimental/j/Elphel333/rtp/daemon/rtp/addrinfo.h
   experimental/j/Elphel333/rtp/daemon/rtp/addrsize.h
   experimental/j/Elphel333/rtp/daemon/rtp/asarray.c
   experimental/j/Elphel333/rtp/daemon/rtp/asarray.h
   experimental/j/Elphel333/rtp/daemon/rtp/autogen.sh
   experimental/j/Elphel333/rtp/daemon/rtp/base64.c
   experimental/j/Elphel333/rtp/daemon/rtp/base64.h
   experimental/j/Elphel333/rtp/daemon/rtp/bills_srtp.h
   experimental/j/Elphel333/rtp/daemon/rtp/bittypes.h
   experimental/j/Elphel333/rtp/daemon/rtp/boxes-fst.dat
   experimental/j/Elphel333/rtp/daemon/rtp/btree.c
   experimental/j/Elphel333/rtp/daemon/rtp/btree.h
   experimental/j/Elphel333/rtp/daemon/rtp/cdecl_ext.h
   experimental/j/Elphel333/rtp/daemon/rtp/common60.dsp
   experimental/j/Elphel333/rtp/daemon/rtp/config.guess
   experimental/j/Elphel333/rtp/daemon/rtp/config.h.in
   experimental/j/Elphel333/rtp/daemon/rtp/config.sub
   experimental/j/Elphel333/rtp/daemon/rtp/config_unix.h
   experimental/j/Elphel333/rtp/daemon/rtp/config_win32.h
   experimental/j/Elphel333/rtp/daemon/rtp/configure
   experimental/j/Elphel333/rtp/daemon/rtp/configure.in
   experimental/j/Elphel333/rtp/daemon/rtp/crypt_random.c
   experimental/j/Elphel333/rtp/daemon/rtp/crypt_random.h
   experimental/j/Elphel333/rtp/daemon/rtp/debug.c
   experimental/j/Elphel333/rtp/daemon/rtp/debug.h
   experimental/j/Elphel333/rtp/daemon/rtp/depcomp
   experimental/j/Elphel333/rtp/daemon/rtp/drand48.c
   experimental/j/Elphel333/rtp/daemon/rtp/drand48.h
   experimental/j/Elphel333/rtp/daemon/rtp/getaddrinfo.c
   experimental/j/Elphel333/rtp/daemon/rtp/gettimeofday.c
   experimental/j/Elphel333/rtp/daemon/rtp/gettimeofday.h
   experimental/j/Elphel333/rtp/daemon/rtp/hmac.c
   experimental/j/Elphel333/rtp/daemon/rtp/hmac.h
   experimental/j/Elphel333/rtp/daemon/rtp/inet_ntop.c
   experimental/j/Elphel333/rtp/daemon/rtp/inet_ntop.h
   experimental/j/Elphel333/rtp/daemon/rtp/inet_pton.c
   experimental/j/Elphel333/rtp/daemon/rtp/inet_pton.h
   experimental/j/Elphel333/rtp/daemon/rtp/install-sh
   experimental/j/Elphel333/rtp/daemon/rtp/ltmain.sh
   experimental/j/Elphel333/rtp/daemon/rtp/mbus.c
   experimental/j/Elphel333/rtp/daemon/rtp/mbus.h
   experimental/j/Elphel333/rtp/daemon/rtp/mbus_addr.c
   experimental/j/Elphel333/rtp/daemon/rtp/mbus_addr.h
   experimental/j/Elphel333/rtp/daemon/rtp/mbus_config.c
   experimental/j/Elphel333/rtp/daemon/rtp/mbus_config.h
   experimental/j/Elphel333/rtp/daemon/rtp/mbus_parser.c
   experimental/j/Elphel333/rtp/daemon/rtp/mbus_parser.h
   experimental/j/Elphel333/rtp/daemon/rtp/md5.c
   experimental/j/Elphel333/rtp/daemon/rtp/md5.h
   experimental/j/Elphel333/rtp/daemon/rtp/memory.c
   experimental/j/Elphel333/rtp/daemon/rtp/memory.h
   experimental/j/Elphel333/rtp/daemon/rtp/missing
   experimental/j/Elphel333/rtp/daemon/rtp/mkinstalldirs
   experimental/j/Elphel333/rtp/daemon/rtp/net_udp.c
   experimental/j/Elphel333/rtp/daemon/rtp/net_udp.h
   experimental/j/Elphel333/rtp/daemon/rtp/ntp.c
   experimental/j/Elphel333/rtp/daemon/rtp/ntp.h
   experimental/j/Elphel333/rtp/daemon/rtp/qfDES.c
   experimental/j/Elphel333/rtp/daemon/rtp/qfDES.h
   experimental/j/Elphel333/rtp/daemon/rtp/rijndael-alg-fst.c
   experimental/j/Elphel333/rtp/daemon/rtp/rijndael-alg-fst.h
   experimental/j/Elphel333/rtp/daemon/rtp/rijndael-api-fst.c
   experimental/j/Elphel333/rtp/daemon/rtp/rijndael-api-fst.h
   experimental/j/Elphel333/rtp/daemon/rtp/rtp.c
   experimental/j/Elphel333/rtp/daemon/rtp/rtp.h
   experimental/j/Elphel333/rtp/daemon/rtp/sockstorage.h
   experimental/j/Elphel333/rtp/daemon/rtp/util.c
   experimental/j/Elphel333/rtp/daemon/rtp/util.h
   experimental/j/Elphel333/rtp/daemon/rtp/version.h
   experimental/j/Elphel333/rtp/daemon/rtp/vsnprintf.c
   experimental/j/Elphel333/rtp/daemon/rtp/vsnprintf.h
   experimental/j/Elphel333/rtp/daemon/rtp/win32/
   experimental/j/Elphel333/rtp/daemon/rtp/win32/Makefile.am
   experimental/j/Elphel333/rtp/daemon/rtp/win32/Makefile.in
   experimental/j/Elphel333/rtp/daemon/rtp/win32/echo.txt
   experimental/j/Elphel333/rtp/daemon/rtp/win32/null.txt
   experimental/j/Elphel333/rtp/daemon/rtp/win32/set.txt
   experimental/j/Elphel333/rtp/daemon/rtp/win32_ver.h
   experimental/j/Elphel333/shout/
   experimental/j/Elphel333/shout/.target-makefrag
   experimental/j/Elphel333/shout/Makefile
   experimental/j/Elphel333/shout/TheoraShout.c
Log:
add some Elphel333 code.



Added: experimental/j/Elphel333/README
===================================================================
--- experimental/j/Elphel333/README	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/README	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,11 @@
+This are three modules for the Elphel 333 Theora camera.
+each module provides a way to access the Theora video stream
+of the camera.
+    http  - provides the video as an Ogg Theora http stream,
+            the same way as streams are provided by icecast2
+    rtp   - provides the video as an RTP Theora stream.
+            this modules provides unicast and multicast rtp
+    shout - with with module you can send and Ogg Theora stream
+            to an icecast2 server. the stream can be configured 
+            via the webinterface
+           

Added: experimental/j/Elphel333/common/.target-makefrag
===================================================================
--- experimental/j/Elphel333/common/.target-makefrag	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/common/.target-makefrag	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1 @@
+AXIS_BUILDTYPE=cris-axis-linux-gnu

Added: experimental/j/Elphel333/common/Makefile
===================================================================
--- experimental/j/Elphel333/common/Makefile	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/common/Makefile	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,25 @@
+#
+# Makefile for the Elphel streamer.
+# This probably requires GNU make.
+#
+AXIS_USABLE_LIBS = UCLIBC GLIBC
+include $(AXIS_TOP_DIR)/tools/build/Rules.axis
+
+
+
+DEFS   = -DHAVE_CONFIG_H
+CFLAGS = -O2 -W  -Wwrite-strings -Wbad-function-cast -Wmissing-prototypes -Wcast-qual -Wmissing-declarations  $(DEFS) 
+LIBS   = -lm 
+
+LD	= ld-cris
+
+OBJS=oggtheora.o utils.o
+SRCS=$(OBJS:%.o=%.c)
+
+all: $(OBJS)
+
+.c.o:
+	$(CC) $(CFLAGS) $(INC) -c $<
+
+clean:
+	-rm -f *.o *~

Added: experimental/j/Elphel333/common/c313a.h
===================================================================
--- experimental/j/Elphel333/common/c313a.h	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/common/c313a.h	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,502 @@
+/*
+ * 05.03.2002 changing for revA
+ * 03.19.2002 Started support for different sensors
+ */
+
+#ifndef _ASM_CMOSCAM_H
+#define _ASM_CMOSCAM_H
+
+/* _IOC_TYPE, bits 8 to 15 in ioctl cmd */
+
+#define CMOSCAM_IOCTYPE 124
+
+/* MINORS */
+
+#define CMOSCAM_MINOR_FRAME	1
+#define CMOSCAM_MINOR_FPN	2
+//#define CMOSCAM_MINOR_IORW	1
+//#define CMOSCAM_MINOR_I2C	2
+//#define CMOSCAM_MINOR_RAW	3
+#define CMOSCAM_MINOR_I2C	3
+#define CMOSCAM_MINOR_DMA	4
+#define CMOSCAM_MINOR_MCP	5
+#define CMOSCAM_MINOR_LOCK	6
+#define CMOSCAM_MINOR_UNLOCK	7
+#define CMOSCAM_MINOR_SENSORJTAGFPGA 8
+#define CMOSCAM_MINOR_RWTABLES 9
+#define CMOSCAM_MINOR_SENSORFPGACOMM 10
+#define CMOSCAM_MINOR_CIRCBUF 11
+#define CMOSCAM_MINOR_CIRCINDEX 12
+
+/* camera sequencer states */
+
+//New sequencer states
+
+#define CAMSEQ_OFF       0 // off, not programmed (Video mode off on Zoran sensors)
+#define CAMSEQ_READY     1 // sensor programmed may acquire at will (programSensor sets number of frames to skip (if any)
+#define CAMSEQ_SKIP      2 // skipping specified number of frames, interrupt service routine counts and will start acquisition
+#define CAMSEQ_WAIT_F 	 3 // set by "start exposure" or interrupt service routine. WAIT_F/WAIT_T/acquire/done differs by hardware register
+#define CAMSEQ_WAIT_T 	 4 // set by "start exposure" or interrupt service routine. Wait/acquire/done differs by hardware register
+#define CAMSEQ_ACQUIRE   5 // acquisition in progress (camSeqState is still CAMSEQ_WAIT)
+#define CAMSEQ_DONE      6 // acquisition over  (camSeqState is still CAMSEQ_WAIT)
+#define CAMSEQ_JPEG      7 // waiting for JPEG done interrupt, acquiring/compressing some frames
+
+#define CAMSEQ_RUN       8 // compressor is constantly running (but if camSeqCount>0 - just skipping "bad" frames)
+#define CAMSEQ_STOP      9 // compressor is constantly running but will stop after next "compressor ready"
+#define CAMSEQ_SINGLE   10 // compressor is constantly running to all the buffer
+/*
+Status CAMSEQ_OFF may be changed to CAMSEQ_READY only by programSensor, it will also stop sensor (if needed)
+  and set camSeqCount (if needed) to skip certain number of frames before actual acquisition
+  camSeqStart (called mostly through ioctl) will return error if state was not "CAMSEQ_READY" or "CAMSEQ_DONE".
+  If called from correct states will either start ISR-based waiting for specified number of frames  or just acquisition.
+  In the first case ISR will start acquisition itself
+  State "CAMSEQ_WAIT_F" is set at the same time as starting acquisition (by either camSeqStart() or ISR),
+  States CAMSEQ_WAIT_F,CAMSEQ_ACQUIRE, CAMSEQ_DONE are returned after testing the hardware register in FPGA if camSeqState==CAMSEQ_WAIT_F
+  camSeqStop will terminate any acquisition in progress and set state to CAMSEQ_READY (if it was not CAMSEQ_OFF)
+*/
+// For KAI11000 sensor board
+#define	sensorcom_W_size	1024
+#define	sensorcom_R_size	256
+
+/* MCP definitions */
+
+#define	MCP_W_size	1024
+#define	MCP_R_size	256
+
+#define	MCPOtherBits	0xffa7a7ff
+#define MCPOffReset	0x00101800
+#define MCPReset	0x00001800
+#define MCPNoReset	0x00105800
+#define MCPToggleA	0x00080000
+#define MCPToggleB	0x00001000
+#define MCPctlseq	0x00
+#define MCPsofttg	0x02
+#define MCPeackn	0x03
+#define MCPctlgate	0x04
+#define MCPwstdly	0x06
+#define MCPwrsmsk	0x07
+#define MCPwrsup	0x08
+#define MCPwrmons	0x09
+#define MCPwnom		0x0a
+#define MCPwdenom	0x0b
+#define MCPwoutw	0x0c
+#define MCPwinvctl	0x0d
+#define MCPctlsync	0x0e
+#define MCPwrdlys	0x10
+#define MCPwinv		0x40
+#define MCPwshared	0x80
+#define MCPwrsynctb	0x100
+#define MCPwrseq	0x200
+
+
+/* supported ioctl _IOC_NR's */
+#ifndef I2C_WRITEARG
+ #define I2C_WRITEARG(bus, slave, reg, value) (((bus) << 24) | ((slave) << 16) | ((reg) << 8) | (value))
+ #define I2C_READARG(bus, slave, reg) (((bus) << 24) | ((slave) << 16) | ((reg) << 8))
+
+ #define I2C_ARGBUS(arg) (((arg) >> 24)  & 0x1)
+ #define I2C_ARGSLAVE(arg) (((arg) >> 16)  & 0xff)
+ #define I2C_ARGREG(arg) (((arg) >> 8) & 0xff)
+ #define I2C_ARGVALUE(arg) ((arg) & 0xff)
+
+ #define I2C_WRITEREG 0x1   /* write to an i2c register */
+ #define I2C_READREG  0x2   /* read from an i2c register */
+#endif
+
+/* new for Micron sensors  - 16bit data, always bus 0 */
+#ifndef I2C_16_WRITEARG
+ #define I2C_16_WRITEREG 0x3   /* write 2 bytes to an i2c register */
+ #define I2C_16_READREG  0x4   /* read 2 bytes from an i2c register */
+  
+ #define I2C_16_WRITEARG(slave, reg, value) (((slave) << 24) | ((reg) << 16) | (value))
+ #define I2C_16_READARG(slave, reg) (((slave) << 24) | ((reg) << 16))
+
+ #define I2C_16_ARGSLAVE(arg)   (((arg) >> 24) & 0xff)
+ #define I2C_16_ARGREG(arg)     (((arg) >> 16) & 0xff)
+ #define I2C_16_ARGVALUE(arg)   ( (arg)      & 0xffff)
+ #define I2C_16_ARGVALUE_H(arg) (((arg) >>  8) & 0xff)
+ #define I2C_16_ARGVALUE_L(arg) ( (arg)        & 0xff)
+#endif
+
+
+
+// otherParamsRO[16]
+
+#define _CCCMD(x,y)  (_IO(CMOSCAM_IOCTYPE, (x << 6) | (y & 0x3f)))
+
+
+
+#define CCAM_CTRL(x)  ((_IOC_NR(x) >> 6) & 0x03)
+#define CCAM_ADDR(x)  (_IOC_NR(x) & 0x3f)
+
+//#define CCAM_RWSENSOR   1 /* direct read/write first 32 sensor registers */  // will not use at all
+#define CCAM_RPARS      2 /* read  parameters      0..0x3f */
+#define CCAM_WPARS      3 /* write parameters      0..0x3f */
+
+/* New parameters and update logic
+ * Separate read and write set of 64 registers
+ * User may specify:
+ *   0 - do not update
+ *   1 - update at once
+ *   2 - update when appropriate
+ * and read update status:
+ *   0 - will not be updated
+ *   1 - in sync
+ *   2 - waiting to be updated
+ *   3 - update in progress (TODO: - support async)
+ * 	When updating (validating) parameters and copying them to the read "registers" the I2C registers will be written
+ *  only if they are different from the shadows
+ */
+
+/* abstract sensor register names */
+#define P_UPDATE         0	    /* R/W, see above */
+#define P_SENSOR         1     /* read only
+                           4  - ZR32112MLC - now there is no way to see color/mono
+                           5  - ZR32112PLC
+                           8  - ZR32212MLC
+                           9  - ZR32112PLC
+                           32 - KAC1310-mono
+                           33 - KAC1310-RGB
+                           34 - KAC1310-CMY
+                           48 - MI1300
+                           49 - MT9M001 (1280x1024,same as MI1300)
+                           50 - MT9M001 (1600x1200)
+                           51 - MT9T001 (2048*1536)
+                           64 - IBIS5-1300*/
+
+// leave it here - may be used in user applications
+#define SENSOR_MASK      0xfc
+#define SENSOR_ZR32112   0x04
+#define SENSOR_ZR32212   0x08
+#define SENSOR_KAC1310   0x20
+#define SENSOR_MI1300    0x30
+#define SENSOR_MT9X001   0x30 // MT9M001 - 1, MT9D001 - 2, MT9T001 - 3
+#define SENSOR_IBIS51300 0x40
+#define SENSOR_KAI11000  0x80
+#define SENSOR_NONE      0xfc
+
+// sensor sizes:
+//#define SENSORWIDTH_ZR32112  1288
+//#define SENSORHEIGHT_ZR32112 1032
+#define SENSORWIDTH_ZR32112  1280
+#define SENSORHEIGHT_ZR32112 1024
+//#define SENSORWIDTH_ZR32212  1288
+#define SENSORWIDTH_ZR32212  1280
+#define SENSORHEIGHT_ZR32212 968
+#define SENSORWIDTH_KAC1310  1280
+#define SENSORHEIGHT_KAC1310 1024
+//#define SENSORWIDTH_KAC1310  1296
+//#define SENSORHEIGHT_KAC1310 1046
+#define SENSORWIDTH_MI1300  1280
+#define SENSORHEIGHT_MI1300 1024
+
+#define SENSORWIDTH_MT9M001  1280
+#define SENSORHEIGHT_MT9M001 1024
+#define SENSORWIDTH_MT9D001  1600
+#define SENSORHEIGHT_MT9D001 1200
+#define SENSORWIDTH_MT9T001  2048
+#define SENSORHEIGHT_MT9T001 1536
+
+#define SENSORWIDTH_IBIS51300  1280
+#define SENSORHEIGHT_IBIS51300 1024
+
+#define P_PARS_CHANGED   2 /* RD P_RO_VALID  0	window parameters valid                  */
+#define P_DMA_VALID      3 /* RD P_RO_VALID  0	window parameters valid                  */
+#define P_ACTUAL_WIDTH   4 /* RD P_RO_WIDTH  1	pixels/row                               */
+#define P_ACTUAL_HEIGHT  5 /* RD P_RO_HEIGHT 2  pixels/column                            */
+#define P_LPR            6 /* RD P_RO_LPR    3	32-bit words per row (aligned each row)  */
+#define P_IMAGE_SIZE     7 /* RD P_RO_SIZE   4	total image size (dma data) in bytes     */
+#define P_BAYER          8 /* filter number at (0,0) 0-R, 1-G(R), 2-G(B), 3 - B. Write enabled at first, move to WindowSize later */
+#define P_TRIGGERED		 9 /* when trigger occured - 4 LSBs - pixel in DMA word, higher bits - number of DMA word */
+#define P_PERIOD        10 // Frame period (read only)
+#define P_FRAME         11 // Frame number (reset with JPEG pointers) -(read only)
+#define P_JPEG_WP       12 // Last reported JPEG write pointer in the circular buffer. May need to be adjustment
+#define P_CLK_FPGA      13 // FPGA clock in MHz
+#define P_CLK_SENSOR    14 // Sensor clock in MHz
+#define P_FPGA_XTRA     15 // Extra cycles needed to compressor (probably constant...)
+
+//#define P_TRIG          16 /* R/W P_RW_TRIG   0	 0 - internal, 1 - external               */
+#define P_TRIG          16 /* External trigger mode                                           */
+                           /* bit 0  - "old" external mode (0- internal, 1 - external )       */
+                           /* bit 1 - enable(1) or disable(0) external trigger to stop clip   */
+                           /* ... to be continued */
+#define P_EXPOS         17 /* P_RW_EXPOS  1	 exposure time                            */
+#define P_BGFRAME       18 // Background measurement mode - will use 16-bit mode and no FPN correction 
+
+//#define P_DMA_SZ        18 // P_RW_DMA_SZ 2	 DMA block size (debug, mostly)
+//#define P_DMA_LOOP      19 // Cyclic DMA buffer (should be updated to multiple of frames)
+
+
+
+
+
+// image page numbers depend on image size/pixel depth, so changing any of them will invalidate all pages
+#define P_PAGE_ACQ      19  // Number of image page buffer to acquire to (0.1?)
+#define P_PAGE_READ     20  // Number of image page buffer to read from to (0.1?)
+
+#define P_OVERLAP       21 // number of EXRA lines to be acquired
+#define P_VIDEO         22 /* still (stopped) - 0, video - 1. KAC1310 - video only */
+
+#define P_AUXCM		23 /* signal on AUXCLK pin: 0 - 0, 1 - 1, 1x - 20MHz */
+
+#define P_VIRT_WIDTH    24 /* Virtual window width - KAC-1310 sensor */
+#define P_VIRT_HEIGHT   25 /* Virtual window height - KAC-1310 sensor */
+#define P_WOI_LEFT      26 /* WOI left corner (before applying decimation) */
+#define P_WOI_TOP       27 /* WOI top corner */
+#define P_WOI_WIDTH     28 /* WOI width */
+#define P_WOI_HEIGHT    29 /* WOI height */
+
+#define P_FLIPH         30
+#define P_FLIPV         31
+#define P_DCM_HOR       32 /* Horizontal decimation (1/2/4/8) */
+#define P_DCM_VERT      33 /* Vertical   decimation (1/2/4/8) copied from horizontal for Zoran chips */
+#define P_BIN_HOR       34 /* binning 1/2 - KAC1310 only */
+#define P_BIN_VERT      35 /* not used yet binning 1/2 - KAC1310 only */
+
+#define P_COLOR         36 /* mono - 0, color mode - 1 */
+#define P_TEST          37 // 0 - normal, 1 - sensor test, 2 - FPGA test
+#define P_MCLK          38 /* 2..129 */
+#define P_MCLK_DIS      39 /* disable sensor clock */
+						 
+#define P_BITS          40 /* pixel depth - bits 10/8/4 */
+#define P_SHIFTL        41 /* "digital gain" - shift left by 0/1/2 bits  (3 ->-1)*/
+#define P_FPNS          42 // FPN correction mode (subtract) 0..3
+                           // 0-none, 1 - fine(25%), 2 - 50%, 3 - coarse(100%)
+#define P_FPNM          43 // FPN correction mode (multiply) 0..3
+                           // 0-none, 1 - fine(+/-12.5%), 2 - medium (+/-25%), +3 - coarse(+/-50%)
+#define P_VEXPOS        44 /* video exposure (if 0 - use P_RW_EXPOS in ms) */
+#define P_VIRTTRIG      45 // Sum of pixels in a line greater than this value - trigger acquisition
+
+#define P_GAINR         46 /* R channel gain (mono gain) */
+#define P_GAING         47 /* G channel gain ("red line" in ZR32212) */
+#define P_GAINB         48 /* B channel gain (mono gain) */
+#define P_GAINGB        49 /* G channel gain ("blue line" in ZR32212) - copied from P_RW_GAING in ZR2112 */
+#define P_FATZERO       50 // subtract while adding data from to consequitive frames (async trigger)
+// will be more for KODAK sensor ?
+#define P_SPEC_KAC_GGA  51 // KAC-1310 Global gain A , 6 bits, (14)
+#define P_SPEC_KAC_GGB  52 // KAC-1310 Global gain B , 6 bits, (14)
+#define P_SPEC_KAC_GGM  53 // KAC-1310 Global gain mode, 3 bits, 0
+#define P_QUALITY       54 // JPEG IMAGE QUALITY
+#define P_FP100S        55 // Frames per 100 sec (fps * 100)
+#define P_SENSOR_WIDTH  56
+#define P_SENSOR_HEIGHT 57
+#define P_COLOR_SATURATION_BLUE 58 // 100*realtive saturation blue
+#define P_COLOR_SATURATION_RED  59 // 100*realtive saturation red
+#define P_GAMMA         60 // 100*gamma  (for now - just a hint table could be more complex. Use higher bytes for colors in 333)
+#define P_PIXEL_LOW     61 //  (just a hint for gamma table) "fat zero" (on 8-bit scale)
+#define P_PIXEL_HIGH    62 //  (just a hint for gamma table) highest pixel value (before table) on a 256-scale
+
+
+#define P_DONTCARE      63 // write anything - just to force update
+
+
+
+
+/*
+EXAMPLE usage:
+
+    i2c_arg = I2C_WRITEARG(STA013_WRITE_ADDR, reg, val);
+    ioctl(fd, _IO(ETRAXI2C_IOCTYPE, I2C_WRITEREG), i2c_arg);
+
+    i2c_arg = I2C_READARG(STA013_READ_ADDR, reg);
+    val = ioctl(fd, _IO(ETRAXI2C_IOCTYPE, I2C_READREG), i2c_arg);
+
+
+*/
+
+
+
+/* i2c errors */
+#ifndef ERR_I2C_SCL_ST0
+ #define	ERR_I2C_SCL_ST0		 1
+ #define	ERR_I2C_SDA_ST0		 2
+ #define	ERR_I2C_SCL_ST1		 4
+ #define	ERR_I2C_SDA_ST1		 8
+ #define	ERR_I2C_SCL_NOPULLUP 16
+ #define	ERR_I2C_SDA_NOPULLUP 32
+
+/* i2c_diagnose called by i2c_start (?) could not find any problems. Try again start */
+ #define    ERR_I2C_NOTDETECTED  64
+ #define	ERR_I2C_SHORT		 128
+ #define	ERR_I2C_BSY		     256
+ #define	ERR_I2C_NACK		 512
+#endif
+
+
+/* supported ioctl _IOC_NR's */
+#define IO_CCAM_SET_EXT_EXPOSURE  0x06
+#define IO_CCAM_MONITOR_SEQ       0x07
+
+
+//#define IO_CCAM_STOP_DMA	0x08
+//#define IO_CCAM_START_DMA	0x09 // just starts DMA - descriptor list should be set eatlier
+//#define IO_CCAM_START_RAW	0x0a // Programs DMA descriptor list according to current frame size, FPGA registers and starts DMA
+
+
+#define IO_CCAM_JPEG		0x08 // JPEG-compressor related commands
+#define      JPEG_CMD_RESET	0x00 //	Resets pointers - both acquisition and readout
+//#define      JPEG_CMD_ARM	0x01 // Prepare compressor to read next frame acquired
+#define      JPEG_CMD_GET	0x02 // Read current page (will return empty (and length==0) if not ready
+#define      JPEG_CMD_FORGET	 0x03 // increment read frame pointer
+#define      JPEG_CMD_CATCHUP	 0x04 // set read pointer to the last acquired (or acquiring if none is acquired yet)
+#define      JPEG_CMD_ACQUIRE	 0x05 // acquire and compress one frame
+#define      JPEG_CMD_SAVE_RP	 0x06 // save read pointer
+#define      JPEG_CMD_RESTORE_RP 0x07 // restore read pointer
+#define      JPEG_CMD_N_DONE     0x08 // return 1 if no more frames to be acquired (frame number)
+#define      JPEG_CMD_L_DONE     0x09 // return 1 if no more frames to be acquired (total length)
+#define      JPEG_CMD_START      0x0a // start constant compression mode
+#define      JPEG_CMD_STOP       0x0b // stop constant compression mode (may want to wait for CAMSEQ_DONE)
+#define      JPEG_CMD_FRAMES     0x0c // returns number of frames in buffer, (re)uilds frames chain
+#define      JPEG_CMD_JUST_STOP  0x0d // just stop - don't start cycle if was allready off!
+#define      JPEG_CMD_DUMP       0x0f // printk all static data/tables
+
+#define      JPEG_CTRL_MONOCHROME    0x400
+#define      JPEG_CTRL_MONOCHROME_BLOCKED    0x1000
+
+#define IO_CCAM_JPEG_QUALITY	0x09 // Set P_QUALITY
+
+#define IO_CCAM_JPEG_GET_N	0x0a	// get specified number of frames (will add to already asked for if any)
+#define IO_CCAM_JPEG_GET_L	0x0b	// get specified length (will stop after frame if got more)
+
+#define IO_CCAM_JPEG_CTRL	0x0c // Write JPEG control word (0x10000 - use header, LSW - other settings)
+#define IO_CCAM_DMA		0x0d
+  #define CCAM_DMA_CMD_STOP	  0x00
+  #define CCAM_DMA_CMD_START  0x01 // just starts DMA - descriptor list should be set eatlier
+
+#define IO_CCAM_CR_MODIFY 0x0e	//(bit number)<<2 | op; op= 0 - nop, 1 - set, 2 - reset, 3 - toggle)
+#define IO_CCAM_CR_SHADOW 0x0f
+
+
+/* Memory mappable memory... can be mmap'd by application.
+*       Contains the following layout:
+*       offset                          content
+*       -------------------             ---------------------
+*       CCAM_MMAP_OFFSET_MMAP_HEADER    struct ccamMmapHeader + fill
+*       CCAM_MMAP_OFFSET_JPEG_HEADER    jpeg header to use + fill
+*       CCAM_MMAP_OFFSET_DMABUF         dma buffer, contiguous
+*/
+
+/* Jpeg dma buffer. Buffer must be a multiple of
+*       64Kbyte because one dma descriptor conveniently handles that many...
+*       (can not handle more than that also).
+*  The #define CCAM_CHUNK_PER_DMABUF can be increased to allow acquiring
+*  larger images, if system memory can be freed up elsewhere.
+*  A value of 128 means 128*64Kbytes per buffer, or 8Mbyte for buffer,
+*  of 16Mbyte total system memory.
+*  Jpeg images rarely get as big as 4MB, but they can get bigger.
+*/
+#define CCAM_BYTES_PER_CHUNK  (1<<16)  /* dma buffer bytes per descriptor */
+#define CCAM_DESCR_PER_CHUNK  1
+/* If CCAM_CHUNK_PER_DMABUF is 100 then buffer is about 6.5 million bytes
+*       which is probably bigger than any single image we'll generate,
+*       and is also bigger than raw data (which is 5.5MB).
+*       However, images bigger than 6.5/2 == 3.25 million bytes will
+*       not be able to be double-buffered and thus will slow things down.
+*/
+//#define CCAM_CHUNK_PER_DMABUF 102  /* no. of 64Kbyte chunks per buffer */
+#define CCAM_CHUNK_PER_DMABUF 300  /* no. of 64Kbyte chunks per buffer */
+#define CCAM_WORDS_PER_DMABUF (CCAM_CHUNK_PER_DMABUF<<14) /*32bit words...*/
+#define CCAM_BYTES_PER_DMABUF (CCAM_CHUNK_PER_DMABUF<<16)
+/*  For past compatibility, CCMA_DMA_SIZE...
+*/
+#define CCAM_DMA_SIZE CCAM_WORDS_PER_DMABUF
+// rather arbitrary - size of indax of frames in buffer, will be limiting factor if frames are less than 256 bytes
+#define CCAM_DMA_INDEX_SIZE (CCAM_DMA_SIZE>>6)
+/*
+*       CCAM_MMAP_OFFSET... -- offsets in bytes in memory mapped region.
+*       CCAM_MMAP_SIZE -- no. of bytes to mmap.
+*/       
+#define CCAM_MMAP_OFFSET_MMAP_HEADER 0
+#define CCAM_MMAP_OFFSET_JPEG_HEADER (PAGE_SIZE)
+#define CCAM_MMAP_OFFSET_DMABUF (4*PAGE_SIZE)
+#define CCAM_MMAP_SIZE (PAGE_SIZE*sizeof(long)+CCAM_BYTES_PER_DMABUF)
+
+// ccamMmapHeader -- Data structure at beginning of mmap'able memory:
+// this allows quick access by an application to this data.
+// NOTE: this must not exceed PAGESIZE bytes since the jpeg header lives there.
+struct ccamMmapHeader
+{
+    /* Application must not change use_header except through setting
+    *  of parameters.
+    */
+    int use_header;     /* should jpeg header/tailer be added? */
+    /* Application must not change headerSize; doing so would only
+    *   confuse
+    */
+    int headerSize;     /* no. of bytes in jpeg header */
+    /* Application may set exposureIdx and jpegIdx to any desired value
+    *   when no acquisition is going on (e.g. before JPEG_CMD_ACQUIRE).
+    */
+    int exposureIdx;    /* incremented on every frame sync (exposure) irupt*/
+    int jpegIdx;        /* incremented on every jpeg done interrupt */
+    /* Data buffering info.
+    *   This is readonly by application, which should use:
+    *   JPEG_CMD_RESET to zero readOffset and writeOffset and buf[readOffset].
+    *   JPEG_CMD_ACQUIRE to acquire image (when done, sets buf[writeOffset]
+    *   and then advances writeOffset and zeroes buf[writeOffset]).
+    *   JPEG_CMD_FORGET to advance readOffset.
+    *
+    *   readOffset and writeOffset are byte offsets from beginning of
+    *   the dma buffer where one can find the respective ccamFileDataHeader.
+    */
+    int readOffset;     /* where we (maybe) can read next image from (bytes) */
+    int writeOffset;    /* where next image will be placed at (bytes) */
+    /* nfr is the number of frames left to acquire in a sequnce of frames 
+    */
+    int nfr;
+    /* lfr is the length (in bytes) of frames left to acquire.
+    *   This is a crude measurement that basically says how much of the
+    *   dma buffer we're willing to consume.
+    */
+    int lfr;
+    /* While dma of jpeg data is enabled/ongoing, jpegBusy is set nonzero.
+    */
+    int jpegBusy;
+};
+
+// ccamFileDataHeader -- Data structure preceding each image in dma buffer.
+// (Note that the actual image may wrap around, but the 
+// this struct is always placed so as to avoid wraparound and be aligned).
+// Note that this does not include jpeg header or tailer, and any way
+// the actual data is in parts (the offset to is given in part[i].offset,
+// a byte count relative to start of dma buffer).
+struct ccamFileDataHeader
+{
+    /* Image is not acquired / valid yet until Valid set to 1 or -1  .
+    *   A value of -1 indicates buffer overflow error.
+    */
+    int valid;
+    /* Value for "valid: (note, OVERFLOW can be recovered from) */
+    #define CCAM_IMAGE_VALIDFLAG_NOTDONE 0  /* MUST be zero */
+    #define CCAM_IMAGE_VALIDFLAG_DONEOK  1 
+    #define CCAM_IMAGE_VALIDFLAG_OVERFLOW -1  /* buffer was too small */
+    #define CCAM_IMAGE_VALIDFLAG_FATAL  -2  /* misc. unexpected error */
+    /* nBytes -- Total size of image stored in dma buffer.
+    *   This does not include e.g. jpeg header (or this header).
+    */
+    int nBytes;
+    /* nBytesMax -- maximum available during acquisition.
+    *   However, the last CCAM_IMAGE_OVERFLOW_BYTES bytes, if used,
+    *   should be taken to indicate that an overlow occurred.
+    *   The value for CCAM_IMAGE_OVERFLOW_BYTES should be large enough
+    *   to accomodate various corrections without adding a bunch of extra logic.
+    */
+    #define CCAM_IMAGE_OVERFLOW_BYTES 512
+    int nBytesMax;
+    /* Offset (bytes) in dma buffer of next image header (IFF Valid is 1) */
+    int nextOffset;
+    /* Offset and size (bytes) in dma buffer of parts of data 
+    *   However, only some part(s) may be used, skip those with zero count.
+    *   Before acq is done, part[i].nBytes is maximum size of the part;
+    *   after acq (when valid is set to 1) it is set to actual amount.
+    *   Two parts is enough for a simple ring buffer approach.
+    */
+    #define CCAM_IMAGE_NPARTS_MAX 2
+    struct
+    {
+        int offset;     /* w/in dma buffer, bytes */
+        int nBytes;     /* size of this part */
+    } part[CCAM_IMAGE_NPARTS_MAX];
+};
+
+#endif /* _ASM_CMOSCAM_H */

Added: experimental/j/Elphel333/common/defines.h
===================================================================
--- experimental/j/Elphel333/common/defines.h	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/common/defines.h	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,103 @@
+// Implementation of Theora RTP streaming
+// Copyright 2005 Elphel, Inc
+// Andrey Latin andrey.latin at gmail.com
+
+#ifndef __STRAMER_H_DEF_
+#define __STREAMER_H_DEF_
+
+#include <inttypes.h>
+
+
+#define HAVE_NANOSLEEP 	1
+
+#define RTP_PT_THEORA	98
+#define BUF_SIZE	1460
+#define TimeScale	90000
+
+#define TimestampTicks	1000000
+
+typedef uint64_t Timestamp;
+typedef uint32_t RtpTimestamp;
+
+#ifndef true
+#define true		1
+#endif
+#ifndef false
+#define false		0
+#endif
+
+
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+#define RAW_TH_DATA	0
+#define TH_IDENT_HDR	0x80
+#define TH_COMMENT_HDR	0x81
+#define TH_SETUP_HDR	0x82
+
+
+// Payload RTP header for Theora bitstream
+
+struct TheoraPayloadHeader {
+	uint32_t	shident:32;	// Setup Header Ident
+	uint8_t		C_bit:1;
+	uint8_t		F_bit:1;
+	uint8_t		reserv:2;
+	uint8_t		n_pkts:4;	// number of complete packets in payload
+	uint8_t		type_payload:8;
+	uint16_t	payload_len;
+};
+
+///////////// for manage streamer with web interface ///////
+#define STOP_STREAM	0
+#define START_STREAM	1
+//#define STOP_SCANNING	0
+//#define START_SCANNING	1
+
+//#define JPEG_ACCESS_MMAP 1
+//#define JPEG_ACCESS_DRV	 2
+
+typedef struct strm_common {
+	char 	address[21];   	// address or hostname
+	int	port;		// port no
+	double	fps;		// soft FPS
+	int     regim;		// mmap/driver access to JPEG data
+	int	scanning;	// mode scanning on/off	 
+	char 	name[21];	// SDES name field for subtitles
+	char	telephone[21];  // phone subtitles
+	char	toolname[21];   
+	char	note[61];
+	char	location[41];
+	char	email[21];
+	char    encrypt_key[41];// encryption key
+	int     encryption;	// mode encryption on/off
+	int	status;		// start/top streamer
+} strm_data_t;
+
+
+
+
+int 		usec_sleep(int);
+Timestamp 	GetTimestamp(void);
+Timestamp	GetTimerMs(void);
+Timestamp 	GetRelativeTime(void);
+void 		InitTimer(void);
+void 		SeedRandom(void);
+uint32_t 	GetRandomMcastAddress(void); 
+uint16_t 	GetRandomPortBlock(void);
+RtpTimestamp 	TimestampToRtp(Timestamp);
+Timestamp 	TimestampToNtp(Timestamp);
+void HexDump(
+        u_int8_t* pBytes, u_int32_t numBytes);
+
+
+
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif //__STRAMER_H_DEF_
+

Added: experimental/j/Elphel333/common/oggtheora.c
===================================================================
--- experimental/j/Elphel333/common/oggtheora.c	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/common/oggtheora.c	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,1809 @@
+/*!***************************************************************************
+*! FILE NAME  : oggtheora.c
+*! DESCRIPTION: TBD
+*! Copyright 2005 Elphel, Inc
+*! -----------------------------------------------------------------------------**
+*!
+*!  oggtheora.c is free software; you can redistribute it and/or modify
+*!  it under the terms of the GNU General Public License as published by
+*!  the Free Software Foundation; either version 2 of the License, or
+*!  (at your option) any later version.
+*!
+*!  oggtheora.c is distributed in the hope that it will be useful,
+*!  but WITHOUT ANY WARRANTY; without even the implied warranty of
+*!  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*!  GNU General Public License for more details.
+*!
+*!  You should have received a copy of the GNU General Public License
+*!  along with oggtheora.c if not, write to the Free Software
+*!  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*! -----------------------------------------------------------------------------**
+*/
+
+/****************** INCLUDE FILES SECTION ***********************************/
+#include <stdio.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <errno.h>
+#include <unistd.h>
+#include <string.h>
+#include "c313a.h"
+#include "oggtheora.h"
+
+
+// used libog-1.1.1/crc/framing.c
+#define OC_NHUFFMAN_TABLES (80)
+#define OC_NDCT_TOKENS     (32)
+
+//#define D(x) x
+#define D(x)
+
+/*A Huffman code for a Theora DCT token.
+  Each set of Huffman codes in a given table must form a complete, prefix-free
+   code.
+  There is no requirement that all the tokens in a table have a valid code,
+   but the current encoder is not optimized to take advantage of this.
+  If there is not at least one table with a code for every token in each of
+   the five groups of 16 tables, then the encoder may fail to encode certain
+   frames.
+  The complete table in the first group of 16 does not have to be in the same
+   place as the complete table in the other groups, but the complete tables in
+   the remaining four groups must all be in the same place.*/
+typedef struct{
+  /*The bit pattern for the code, with the LSbit of the pattern aligned in
+     the LSbit of the word.*/
+  u_int32_t pattern;
+  /*The number of bits in the code.
+    This must be between 0 and 32, inclusive.*/
+  int          nbits;
+}theora_huff_code;
+
+#define ogg_uint32_t u_int32_t
+
+#include "oggtheora_tables.h"
+
+// from theora/experimental/include/theora/theora.h
+#define OC_EINVAL    (-10)
+
+// from theora/experimental/lib/ocintrin.h
+#define OC_MAXI(_a,_b)      ((_a)<(_b)?(_b):(_a))
+
+// from theora/libogg-1.1.1/include/ogg/ogg.h
+typedef struct {
+  long endbyte;
+  int  endbit;
+
+  unsigned char *buffer;
+  unsigned char *ptr;
+  long storage;
+} oggpack_buffer;
+
+
+// from theora/experimental/lib/huffenc.c
+
+/*A description of a Huffman code value used when encoding the tree.*/
+typedef struct{
+  /*The bit pattern, left-shifted so that the MSB of all patterns is
+     aligned.*/
+  ogg_uint32_t pattern;
+//  u_int32_t pattern;
+  /*The amount the bit pattern was shifted.*/
+  int          shift;
+  /*The token this bit pattern represents.*/
+  int          token;
+}oc_huff_entry;
+       extern int errno;
+
+
+//#define C333_MAXWIDTH (4096)
+//#define C333_MAXHEIGHT (2048)
+// FPGA_MASK is used to specify (macroblock*4)-level "skip" and "low quality" (qi[0] - high, qi[1] - low)
+// skip applies to some INTER frames and will not be coded.
+// the mask is made for the 128x64 macroblock array, (0,0) matching the lower-left corner of the image
+// each element (u_int_16) encodes 8 macroblock flag pairs (LSB left, in each pair lower bit is quality,
+// higher - "skip"
+
+/*
+static u_int16_t FPGA_MASK[C333_MAXHEIGHT>>5][C333_MAXWIDTH>>8]; // [64][16]
+static const u_int32_t FPGA_ZEROBIN[6]={ // Index Sharpness S.Fact>50 Zbin       Round
+                                 0x80a6, //   0       0        0      0.65(166)  0.499(128)
+                                 0x76a6, //   1       0        1      0.65(166)  0.460(118)
+                                 0x7ac0, //   2       1        0      0.75(192)  0.476(122)
+                                 0x66c0, //   3       1        1      0.75(192)  0.400(102)
+                                 0x7ae6, //   4       2        0      0.90(230)  0.476(122)
+                                 0x55e6};//   5       2        1      0.90(230)  0.333( 85)
+static u_int32_t FPGA_QTABLES[512];
+static u_int16_t FPGA_HTI     [12];
+static u_int16_t FPGA_HTI30   [16];
+static u_int32_t FPGA_HTABLE  [1024];
+static u_int16_t FPGA_FIRSTBIT[4];
+
+*/
+
+   
+  void fill_FPGA_qtable (u_int32_t *table,
+                         int       inter,
+                         int       color,
+                         int       qindex_dc, // always the same in a frame
+                         int       qindex_ac, // may be different if it is a second qi in a frame
+                         int       sharpness);  // 0..2 - common for all q
+   void fill_FPGA_qtables (
+     u_int32_t  tables[512],
+     int  sharpness,
+     int  intra_y_qi_hi,   // index in DC_Scale/AC_Scale tables, intra frame, luma
+     int  intra_c_qi_hi,   // index in DC_Scale/AC_Scale tables, intra frame, chroma
+     int  inter_y_qi_hi,   // index in DC_Scale/AC_Scale tables, inter frame, luma
+     int  inter_c_qi_hi,   // index in DC_Scale/AC_Scale tables, inter frame, chroma
+
+     int  intra_y_qi_lo,   // index in DC_Scale/AC_Scale tables, intra frame, luma
+     int  intra_c_qi_lo,   // index in DC_Scale/AC_Scale tables, intra frame, chroma
+     int  inter_y_qi_lo,   // index in DC_Scale/AC_Scale tables, inter frame, luma
+     int  inter_c_qi_lo);   // index in DC_Scale/AC_Scale tables, inter frame, chroma
+  // {len[3:0],data[13:0]} - data is MSB aligned
+   int fill_FPGA_htables (u_int16_t hti  [12],
+                          u_int16_t hti30[16],
+                          u_int32_t htable[1024],
+                          int       pre_ht[12],
+                          int       pre_ht30[6]);
+
+
+int theora_write_bits (char * buf, // buffer
+                          int * bp,   // pointer to bit pointer
+                          u_int32_t data,   // data to write
+                          int nb);     // number of bits to write
+static int huff_entry_cmp(const void *_c1,const void *_c2);
+
+int oc_huff_codes_pack(char *buf, int* bp,
+ const theora_huff_code _codes[OC_NHUFFMAN_TABLES][OC_NDCT_TOKENS]);
+
+int ogg_page      (ogg_header_t *    ogg_header, // pointer to the header data (returns - header length in bytes)
+                            char     flags,
+                            u_int64_t granule,
+                            u_int32_t stream_serial,
+                            int      page,       // page
+                            int      num_packets, // number of packets in the page
+                   len_data_t *      packets);
+
+/*
+    similar to above, but dedicated to the frame data.
+    There could be 2 types
+    - first page of a frame (packet) then frame header will be attached 
+      and bit-combined with the frame
+    - continuation  page (flags bit 0 should be set) - 
+        then no frame header will be added to the data
+    currently there can not be two frames (packets) on one page
+*/
+int ogg_frame_page      (ogg_header_t *    ogg_header,      // pointer to the header data (returns - header length in bytes)
+                            char           flags,           // +1 - continuation, +4 - last (+2 - first)
+                            int            maxpage,         // maximal page size (w/o ogg header)
+                            u_int64_t      granule,         // 
+                            u_int32_t      stream_serial,   //
+                            int            page,            // page
+                            len_data_t     frame_header,    // not used if (flags & 1). frame_header.len is measured in bits, not bytes!
+                            int          * len,             // pointer frame data length (will modify - if non-zero - need continuation)
+                            u_int8_t    ** frame_data);     // pointer to pointer to an array with frame data
+                                                            // if it is not continuation data is bit-aligned to be combined with frame_header
+                                                            // first word of frame data will be modified - OR-ed with the last one from
+                                                            // the frame_header
+                   
+                   
+int theora_identification (char *buf,  // returns length, buf should be big enough - 42 bytes
+                              int   fmbw, // width in macroblocks
+                              int   fmbh, // height in macroblocks
+                              int   frn, // frame rate nominator ( in 1/1000000)
+                              int   frd, // frame rate denominator (1000000)
+                              int   nobr, // nominal bit rate (-1 - undefined?)
+                              int   qual, // relative quality (was 0x10)
+                              int   kfgshift); // number of bits in granule used for number of i-frames
+int theora_comments (char       *buf,    // returns length, buf should be big enough - ?? bytes
+                        int         buflen,  // buffer size (returns -1 if fails to fit)
+                        const char *vendor, // Null-terminated string (was "Xiph.Org libTheora I 20040317 3 2 0\0")
+                        int         nuser,   // number of user comments
+                        const char **user);
+   int theora_setup (char       *buf,    // returns length, buf should be big enough - ?? bytes
+                     int         buflen,  // buffer size (returns -1 if fails to fit)
+// the next pointers will likely point to constant tables, the same ones should be used to program FPGA internal tables                     
+                     const int  *lflims,  // if null - skip  alltogether, not null - 5 assumed bits/value
+                     const int  *acscale, // will encode 10bits/item
+                     const int  *dcscale, // will encode 10bits/item
+                     const int  bms[][64]    // array of 3 BMS tables
+                        );
+void fill_fpga_mask_windows (u_int16_t  mask_array[C333_MAXHEIGHT>>5][C333_MAXWIDTH>>8],
+                           int width,
+                           int height, 
+                           int qual_left, // all in pixels, high quality will be inside and including the spacified coordinates
+                           int qual_bottom,
+                           int qual_right,
+                           int qual_top,
+                           int skip_left,
+                           int skip_bottom,
+                           int skip_right,
+                           int skip_top);
+   int theora_frameheader (char       *buf,    // returns length, buf should be big enough - ?? bytes
+                           int         buflen,  // buffer size (returns -1 if fails to fit) - not implemented yet
+                           int         width,   // pixels - will ">>" as needed
+                           int         height,  // pixels - will ">>" as needed
+                           int         frame_flags,   // 0 - intra, 1 - inter(full), 3 - inter (skip according mask)
+                           int         nqis,     // number of qi in a frame (valid 1 or 2)
+                           int         qis[2], // q[0] - high, DC, q[1] - low (AC only)
+                          
+                           u_int16_t   mask_array[C333_MAXHEIGHT>>5][C333_MAXWIDTH>>8] //
+//                           int mask_array[C333_MAXHEIGHT>>5][C333_MAXWIDTH>>8] //
+                        );
+   void theora_frameheaders(int         width,   // pixels - will ">>" as needed
+                           int         height,  // pixels - will ">>" as needed
+                           len_data_t  frame_headers[3],   // [0] - intra, [1] - inter(full), [2] - inter (skip according mask)
+                           int         nqis,     // number of qi in a frame (valid 1 or 2)
+                           int         qis[2], // q[0] - high, DC, q[1] - low (AC only)
+                           u_int16_t   mask_array[C333_MAXHEIGHT>>5][C333_MAXWIDTH>>8] //
+                        );
+
+
+
+    int makeOggTheora(u_int32_t * ccam_dma_index, // will be mmaped array in the camera
+                      u_int8_t  * ccam_dma,       // will be mmaped array in the camera (char array)
+                      FILE *      movie_file,
+                      int         page_size,  // maximal; page size to use
+                      len_data_t  packets[6], // 0 - identification
+                                              // 1 - comment
+                                              // 2 - setup
+                                              // 3 - frame - intra (.len - in bits, not bytes!)
+                                              // 4 - frame - inter/full
+                                              // 5 - frame - inter/mapped
+                      u_int32_t   stream_serial,
+                      int         kfgshiftm // number of bits in granule used for number of i-frames
+                      );
+                      
+   void write_7_2_1(char * buf,         // bitstream buffer
+                    int  * bp,          // bitstream bit pointer
+                    int    length);     // run length to encode
+   
+   void write_7_2_2(char * buf,         // bitstream buffer
+                    int  * bp,          // bitstream bit pointer
+                    int    length);     // run length to encode
+   
+   void   put_7_2_1(char * buf,         // bitstream buffer
+                    int  * bp,          // bitstream bit pointer
+                    int  * current_bit, // current running bit (-1 - undefined)
+                    int  * run,         // current length of bits (when current bit == -1 undefined)
+                    int    bit,         // bit to encode (<0 - flush)
+                    int    len);        // number of bits to put
+
+   void   put_7_2_2(char * buf,         // bitstream buffer
+                    int  * bp,          // bitstream bit pointer
+                    int  * current_bit, // current running bit (-1 - undefined)
+                    int  * run,         // current length of bits (when current bit == -1 undefined)
+                    int    bit,         // bit to encode (<0 - flush)
+                    int    len);        // number of bits to put
+
+                           
+//++++++++++++++++++++++++++++++++++++++++++++++
+
+void fill_fpga_mask_windows (u_int16_t  mask_array[C333_MAXHEIGHT>>5][C333_MAXWIDTH>>8],
+                           int width,
+                           int height, 
+                           int qual_left, // all in pixels, high quality will be inside and including the spacified coordinates
+                           int qual_bottom,
+                           int qual_right,
+                           int qual_top,
+                           int skip_left,
+                           int skip_bottom,
+                           int skip_right,
+                           int skip_top) {
+    const int mask[8]={3,0xc,0x30,0xc0,0x300,0xc00,0x3000,0xc000};
+    int x,y,x8,d;
+    int w  = (width-1)   >> 5;
+    int h  = (height-1)  >> 5;
+    int ql = qual_left   >> 5;
+    int qb = qual_bottom >> 5;
+    int qr = qual_right  >> 5;
+    int qt = qual_top    >> 5;
+    int sl = skip_left   >> 5;
+    int sb = skip_bottom >> 5;
+    int sr = skip_right  >> 5;
+    int st = skip_top    >> 5;
+    if (w>((C333_MAXWIDTH >>5) -1)) w=((C333_MAXWIDTH >>5) -1);
+    if (h>((C333_MAXHEIGHT>>5) -1)) h=((C333_MAXHEIGHT>>5) -1);
+D(fprintf(stderr,"fill_fpga_mask_windows w=%d, h=%d\n",w,h));
+D(fprintf(stderr,"ql=%d qb=%d qr=%d qt=%d sl=%d sb=%d sr=%d st=%d\n",ql,qb,qr,qt,sl,sb,sr,st));
+     
+// this implementation is not optimized for speed - it is possible to do later.
+    for (y=0;y<=h;y++) for (x=0;x<=w;x++) {
+      d=((((x>qr) || (x<ql) || (y>qt) || (y<qb))? 1 : 0) |
+         (((x>sr) || (x<sl) || (y>st) || (y<sb))? 2 : 0)) << ((x & 7) << 1);
+         x8=x>>3;
+         mask_array[y][x8] ^= ((mask_array[y][x8] ^ d) & mask[x & 7]);
+D(if (d>0) fprintf(stderr,"d= 0x%x, x=%d, mask_array[%d][%d]=0x%x\n",d,x,y,x8,mask_array[y][x8]));
+         
+    }
+}
+
+
+   void write_7_2_1(char * buf,         // bitstream buffer
+                    int  * bp,          // bitstream bit pointer
+                    int    length)      // run length to encode
+   {
+     if        (length>=34) {
+       theora_write_bits (buf, bp,  0x3f,6);
+       theora_write_bits (buf, bp,  length-34,12);
+     } else if (length>=18) {
+       theora_write_bits (buf, bp,  0x3e,6);
+       theora_write_bits (buf, bp,  length-18,4);
+     } else if (length>=10) {
+       theora_write_bits (buf, bp,  0x1e,5);
+       theora_write_bits (buf, bp,  length-10,3);
+     } else if (length>= 6) {
+       theora_write_bits (buf, bp,  0x0e,4);
+       theora_write_bits (buf, bp,  length- 6,2);
+     } else if (length>= 4) {
+       theora_write_bits (buf, bp,  0x06,3);
+       theora_write_bits (buf, bp,  length-4,1);
+     } else if (length>= 2) {
+       theora_write_bits (buf, bp,  0x02,2);
+       theora_write_bits (buf, bp,  length-2,1);
+     } else  {
+       theora_write_bits (buf, bp,  0x00,1);
+     }
+     
+   }
+   
+   void write_7_2_2(char * buf,         // bitstream buffer
+                    int  * bp,          // bitstream bit pointer
+                    int    length)      // run length to encode
+   {
+     if        (length>=15) {
+       theora_write_bits (buf, bp,  0x1f,5);
+       theora_write_bits (buf, bp,  length-15,4);
+     } else if (length>=11) {
+       theora_write_bits (buf, bp,  0x1e,5);
+       theora_write_bits (buf, bp,  length-11,2);
+     } else if (length>= 7) {
+       theora_write_bits (buf, bp,  0x0e,4);
+       theora_write_bits (buf, bp,  length- 7,2);
+     } else if (length>= 5) {
+       theora_write_bits (buf, bp,  0x06,3);
+       theora_write_bits (buf, bp,  length-5,1);
+     } else if (length>= 3) {
+       theora_write_bits (buf, bp,  0x02,2);
+       theora_write_bits (buf, bp,  length-3,1);
+     } else  {
+       theora_write_bits (buf, bp,  0x00,1);
+       theora_write_bits (buf, bp,  length-1,1);
+     }
+     
+   }
+   
+   void put_7_2_1(char * buf,         // bitstream buffer
+                  int  * bp,          // bitstream bit pointer
+                  int  * current_bit, // current running bit (-1 - undefined)
+                  int  * run,         // current length of bits (when current bit == -1 undefined)
+                  int    bit,         // bit to encode (<0 - flush)
+                  int    len)         // number of bits to put
+   {
+//  D(fprintf(stderr, "put_7_2_1: put %d of bit %d\n",len,bit));
+     if (current_bit[0]<0) {
+       if (bit >=0) { // do nothing for empty string
+         theora_write_bits (buf, bp,  bit, 1); // start new run
+         current_bit[0]=bit;
+         run[0]=len;
+         while (run[0]>=4129) {
+           write_7_2_1(buf, bp, 4129);
+           run[0]-=4129;
+           if (run[0]>0) theora_write_bits (buf, bp,  bit, 1);
+           else current_bit[0]=-1;
+         }
+       }
+     } else { // current_bit >= 0
+       if (bit <0) { //flush
+         write_7_2_1(buf, bp, run[0]);
+         current_bit[0]=-1;
+//         run[0]=0; //?  not needed
+       } else { // continue
+         if (bit == current_bit[0]) {
+           run[0]+=len;
+           while (run[0]>=4129) {
+             write_7_2_1(buf, bp, 4129);
+             run[0]-=4129;
+             if (run[0]>0) theora_write_bits (buf, bp,  bit, 1);
+             else current_bit[0]=-1;
+           }
+         } else { // bit flipped
+           write_7_2_1(buf, bp, run[0]);
+           current_bit[0]=bit;
+           run[0]=len;
+           while (run[0]>=4129) {
+             write_7_2_1(buf, bp, 4129);
+             run[0]-=4129;
+             if (run[0]>0) theora_write_bits (buf, bp,  bit, 1);
+             else current_bit[0]=-1;
+           }
+         }
+       }
+     } 
+   }
+   
+   
+   void put_7_2_2(char * buf,         // bitstream buffer
+                  int  * bp,          // bitstream bit pointer
+                  int  * current_bit, // current running bit (-1 - undefined)
+                  int  * run,         // current length of bits (when current bit == -1 undefined)
+                  int    bit,         // bit to encode (<0 - flush)
+                  int    len)         // number of bits to put
+   {
+//  fprintf(stderr, "put_7_2_2: put %d of bit %d\n",len,bit);  
+     if (current_bit[0]<0) {
+       if (bit >=0) { // do nothing for empty string
+         theora_write_bits (buf, bp,  bit, 1); // start new run
+         current_bit[0]=bit;
+         run[0]=len;
+         while (run[0]>=30) {
+           write_7_2_2(buf, bp, 30);
+           run[0]-=30;
+           if (run[0]>0) theora_write_bits (buf, bp,  bit, 1);
+           else current_bit[0]=-1;
+         }
+       }
+     } else { // current_bit >= 0
+       if (bit <0) { //flush
+         write_7_2_2(buf, bp, run[0]);
+         current_bit[0]=-1;
+//         run[0]=0; //?  not needed
+       } else { // continue
+         if (bit == current_bit[0]) {
+           run[0]+=len;
+           while (run[0]>=30) {
+             write_7_2_2(buf, bp, 30);
+             run[0]-=30;
+             if (run[0]>0) theora_write_bits (buf, bp,  bit, 1);
+             else current_bit[0]=-1;
+           }
+         } else { // bit flipped
+           write_7_2_2(buf, bp, run[0]);
+           current_bit[0]=bit;
+           run[0]=len;
+           while (run[0]>=30) {
+             write_7_2_2(buf, bp, 30);
+             run[0]-=30;
+             if (run[0]>0) theora_write_bits (buf, bp,  bit, 1);
+             else current_bit[0]=-1;
+           }
+         }
+       }
+     } 
+   }
+   
+   int theora_frameheader (char       *buf,    // returns length, buf should be big enough - ?? bytes
+                           int         buflen,  // buffer size (returns -1 if fails to fit) - not implemented yet
+                           int         width,   // pixels - will ">>" as needed
+                           int         height,  // pixels - will ">>" as needed
+                           int         frame_flags,   // 0 - intra, 1 - inter(full), 3 - inter (skip according mask)
+                           int         nqis,     // number of qi in a frame (valid 1 or 2)
+                           int         qis[2], // q[0] - high, DC, q[1] - low (AC only)
+                           u_int16_t   mask_array[C333_MAXHEIGHT>>5][C333_MAXWIDTH>>8] //
+                          )
+   {
+  D(fprintf(stderr, "theora_frameheader, frame_flags=%d, nqis=%d, qis[0]=%d,  qis[1]=%d\n",frame_flags,nqis,qis[0],qis[1]));
+   
+   int block_lev[C333_MAXHEIGHT>>6][C333_MAXWIDTH>>8]; // [32][16]
+   int bp=0;
+   int current_bit=-1;
+   int run=0;
+     
+   int nstx=(width  >> 7);
+   int nsty=(height >> 6);
+   int nst=  nsty * nstx;
+   int nsbs= nst  * 12;  // number of all superblocks (32x32)
+   int nsbl= nst  * 8;   // number of luma superblocks
+//   int nsbc= nst  * 2;   // number of superblocks for each color plane
+//   int nbs=  nsbs << 4;  // total number of blocks
+//   int sbpcoded;
+//   int sbfcoded;
+   int x,x8,xf,y,d,d1,d2,c,ncmbs,i;
+   if (nqis>2) return -1;
+   theora_write_bits (buf, &bp,  0,            1); // data packet
+   theora_write_bits (buf, &bp,  frame_flags,  1); // frame type
+   for (i=0; i<nqis; i++) {
+     theora_write_bits (buf, &bp,  qis[0],       6); // high quality, then low one (if present)
+     theora_write_bits (buf, &bp,  (i<(nqis-1))?1:0, 1); // more QIS
+   }
+  D(fprintf(stderr, "qis out - bp=%d\n",bp));
+   if (frame_flags==1) { // inter full
+     put_7_2_1(buf, &bp, &current_bit, &run, 0, nsbs); // no partially coded superblocks;
+     put_7_2_1(buf, &bp, &current_bit, &run, -1, 0); // flush
+     put_7_2_1(buf, &bp, &current_bit, &run, 1, nsbs); // all superblocks fully coded;
+     put_7_2_1(buf, &bp, &current_bit, &run, -1, 0); // flush
+  D(fprintf(stderr, "(1) - bp=%d\n",bp));
+   } else if (frame_flags==3) { // inter - use mask
+     put_7_2_1(buf, &bp, &current_bit, &run, 0, nsbl); // no partially coded superblocks in luma;
+     for (y=0;y<(height>>5);y+=2) for (x=0;x<(width>>5);x+=2) { // build array
+       x8=x>>3;
+       xf= ((x>>1) & 3)<<2;
+       d1= mask_array[y  ][x8]>>xf;
+       d2= mask_array[y+1][x8]>>xf;
+       d= ((d1 & 2)?0:1) | ((d2 & 2)?0:2) | ((d2 & 8)?0:4) | ((d1 & 8)?0:8);
+       block_lev[y>>1][x8] =( (block_lev[y>>1][x8] ^ (d<<xf)) & (0xf << xf)) ^ block_lev[y>>1][x8];
+       put_7_2_1(buf, &bp, &current_bit, &run, ((d!=0) && (d!=0xf))?1:0, 1); // specify partial for Cb
+     }
+  D(fprintf(stderr, "(2) - bp=%d\n",bp));
+     for (y=0;y<(height>>5);y+=2) for (x=0;x<(width>>5);x+=2) { // build array
+       x8=x>>3;
+       xf= ((x>>1) & 3)<<2;
+       d= (block_lev[y>>1][x8]>>xf) & 0xf;
+       put_7_2_1(buf, &bp, &current_bit, &run, ((d!=0) && (d!=0xf))?1:0, 1); // specify partial for Cr
+     }
+     put_7_2_1(buf, &bp, &current_bit, &run, -1, 0); // flush
+// now - fully coded
+// luma first
+  D(fprintf(stderr, "(3) - bp=%d\n",bp));
+     ncmbs=0; // also count number of coded macroblocks (here - groups of 4)
+     for (y=0;y<(height>>5);y++) for (x=0;x<(width>>5);x++) {
+//       put_7_2_1(buf, &bp, &current_bit, &run,((mask_array[y  ][x>>3]>>((x&7)<<1)) & 2)?0:1,1);
+       c=((mask_array[y  ][x>>3]>>((x&7)<<1)) & 2)?0:1;
+       put_7_2_1(buf, &bp, &current_bit, &run,c,1);
+       ncmbs+=c;
+     }  
+// repeat twice - for Cb and Cr
+  D(fprintf(stderr, "(4) - bp=%d\n",bp));
+     for (i=0;i<2;i++) for (y=0;y<(height>>5);y+=2) for (x=0;x<(width>>5);x+=2) {
+       x8=x>>3;
+       xf= ((x>>1) & 3)<<2;
+       d= (block_lev[y>>1][x8]>>xf) & 0xf;
+       put_7_2_1(buf, &bp, &current_bit, &run, (d==0)?1:0, 1); // fully coded
+     }
+     put_7_2_1(buf, &bp, &current_bit, &run, -1, 0); // flush
+// partially coded - repeat twice (for Cb and Cr)
+  D(fprintf(stderr, "(5) - bp=%d\n",bp));
+     
+     for (i=0;i<2;i++) for (y=0;y<(height>>5);y+=2) for (x=0;x<(width>>5);x+=2) { 
+       x8=x>>3;
+       xf= ((x>>1) & 3)<<2;
+       d= (block_lev[y>>1][x8]>>xf) & 0xf;
+       if ((d!=0) && (d!=0xf)) {
+         put_7_2_2(buf, &bp, &current_bit, &run, (d & 1)?0:1, 4); // 4 blocks
+         put_7_2_2(buf, &bp, &current_bit, &run, (d & 2)?0:1, 4); // 4 blocks
+         put_7_2_2(buf, &bp, &current_bit, &run, (d & 4)?0:1, 4); // 4 blocks
+         put_7_2_2(buf, &bp, &current_bit, &run, (d & 8)?0:1, 4); // 4 blocks
+
+       }
+     }
+     put_7_2_1(buf, &bp, &current_bit, &run, -1, 0); // flush
+   } else theora_write_bits (buf, &bp,  0, 3);  // 3 bits 0 for intra only
+   
+  D(fprintf(stderr, "(6) - bp=%d\n",bp));
+
+   if (frame_flags!=0) { // inter any
+     ncmbs=32*nst; // all coded - 32 macroblocks per supertile
+// macroblock coding modes - all INTER_NOMV (0), so using scheme 5 that codes it as a single bit "0"
+  D(fprintf(stderr, "ncmbs=%d\n",ncmbs));
+     theora_write_bits (buf, &bp,  5, 3); // 3 bits - mscheme=5
+     for (;ncmbs>=32;ncmbs-=32) theora_write_bits (buf, &bp,  0, 32); // 32 of coded macroblcks
+     theora_write_bits (buf, &bp,  0, ncmbs); // <32 of coded macroblcks
+  }
+// For all INTER frames one bit MVMODE should be here, even if it is not used (inter_nomv)
+   if (frame_flags!=0) // inter any
+     theora_write_bits (buf, &bp,  0, 1);
+    
+// block-level qi
+  D(fprintf(stderr, "(7) - bp=%d\n",bp));
+   if (nqis>1) {
+// for luma blocks granularity is now 1 superblock (16 blocks) so no need for Hilbert    
+     if (current_bit>=0) return -2; // should be closed
+// now - fully coded
+// luma first
+     for (y=0;y<(height>>5);y++) for (x=0;x<(width>>5);x++) {
+       put_7_2_1(buf, &bp, &current_bit, &run,((mask_array[y  ][x>>3]>>((x&7)<<1)) & 1)?1:0,16);
+     }
+  D(fprintf(stderr, "(8) - bp=%d\n",bp));
+     for (y=0;y<(height>>5);y+=2) for (x=0;x<(width>>5);x+=2) { // process Cb, build array
+       x8=x>>3;
+       xf= ((x>>1) & 3)<<2;
+       d1= mask_array[y  ][x8]>>xf;
+       d2= mask_array[y+1][x8]>>xf;
+       d= ((d1 & 1)?1:0) | ((d2 & 1)?2:0) | ((d2 & 4)?4:0) | ((d1 & 4)?8:0);
+       block_lev[y>>1][x8] ^= (block_lev[y>>1][x8] ^ (d<<xf)) & (0xf << xf);
+       put_7_2_1(buf, &bp, &current_bit, &run, (d    ) & 1, 4);// four blocks with the same qi
+       put_7_2_1(buf, &bp, &current_bit, &run, (d >>1) & 1, 4);// four blocks with the same qi
+       put_7_2_1(buf, &bp, &current_bit, &run, (d >>2) & 1, 4);// four blocks with the same qi
+       put_7_2_1(buf, &bp, &current_bit, &run, (d >>3) & 1, 4);// four blocks with the same qi
+     }
+  D(fprintf(stderr, "(9) - bp=%d\n",bp));
+     for (y=0;y<(height>>5);y+=2) for (x=0;x<(width>>5);x+=2) { // build array
+       x8=x>>3;
+       xf= ((x>>1) & 3)<<2;
+       d= (block_lev[y>>1][x8]>>0xf) & 0xf;
+       put_7_2_1(buf, &bp, &current_bit, &run, (d    ) & 1, 4);// four blocks with the same qi
+       put_7_2_1(buf, &bp, &current_bit, &run, (d >>1) & 1, 4);// four blocks with the same qi
+       put_7_2_1(buf, &bp, &current_bit, &run, (d >>2) & 1, 4);// four blocks with the same qi
+       put_7_2_1(buf, &bp, &current_bit, &run, (d >>3) & 1, 4);// four blocks with the same qi
+     }
+  D(fprintf(stderr, "(10) - bp=%d\n",bp));
+     
+     put_7_2_1(buf, &bp, &current_bit, &run, -1, 0); // flush
+  D(fprintf(stderr, "(11) - bp=%d\n",bp));
+     
+   }
+   return bp;
+  }
+
+
+   void theora_frameheaders(int         width,   // pixels - will ">>" as needed
+                           int         height,  // pixels - will ">>" as needed
+//                           int         frame_flags,   // 0 - intra, 1 - inter(full), 3 - inter (skip according mask)
+                           len_data_t  frame_headers[3],   // [0] - intra, [1] - inter(full), [2] - inter (skip according mask)
+                           int         nqis,     // number of qi in a frame (valid 1 or 2)
+                           int         qis[2], // q[0] - high, DC, q[1] - low (AC only)
+                           u_int16_t   mask_array[C333_MAXHEIGHT>>5][C333_MAXWIDTH>>8] //
+                        )
+    {
+      char * buf;
+      int    i;
+      buf = malloc(64000); //?? maximal size?
+      frame_headers[0].len= theora_frameheader(buf, 64000, width, height, 0, nqis, qis,  mask_array);
+      for (i=frame_headers[0].len; i<(((frame_headers[0].len+31)>>3)& (~0x3)); i++) buf[i]=0;
+      frame_headers[0].data=malloc(((frame_headers[0].len+31)>>3)& (~0x3));
+      memcpy (frame_headers[0].data,buf,((frame_headers[0].len+31)>>3)& (~0x3));
+      
+      frame_headers[1].len= theora_frameheader(buf, 64000, width, height, 1, nqis, qis,  mask_array);
+      for (i=frame_headers[1].len; i<(((frame_headers[1].len+31)>>3)& (~0x3)); i++) buf[i]=0;
+      frame_headers[1].data=malloc(((frame_headers[1].len+31)>>3)& (~0x3));
+      memcpy (frame_headers[1].data,buf,((frame_headers[1].len+31)>>3)& (~0x3));
+
+      frame_headers[2].len= theora_frameheader(buf, 64000, width, height, 3, nqis, qis,  mask_array);
+      for (i=frame_headers[2].len; i<(((frame_headers[2].len+31)>>3)& (~0x3)); i++) buf[i]=0;
+      frame_headers[2].data=malloc(((frame_headers[2].len+31)>>3)& (~0x3));
+      memcpy (frame_headers[2].data,buf,((frame_headers[2].len+31)>>3)& (~0x3));
+    }
+  
+   int theora_write_bits (char * buf, // buffer
+                          int * bp,   // pointer to bit pointer
+                          u_int32_t data,   // data to write
+                          int nb)     // number of bits to write
+   {
+     int i,m, bytp,bitp;
+     if (((*bp | nb) & 7) == 0) { // byte sync not lost
+       for (i=(nb-8); i>=0; i-=8) {
+         buf[(*bp)>>3]=(data>>i) & 0xff;
+         *bp+=8;
+       }
+     } else while (nb>0){ // processing on bit level
+       m= 0xff >> (bitp=((*bp) & 7));
+       bytp=(*bp)>>3;
+       if ((bitp+nb)>=8) {
+         buf[bytp]=((buf[bytp] ^ (data >> (bitp+nb-8))) & m) ^ buf[bytp];
+         *bp=(bytp+1)<<3;
+         nb-=(8-bitp);
+       } else {
+         buf[bytp]=((buf[bytp] ^ (data << (8-bitp-nb))) & m) ^ buf[bytp];
+         *bp+=nb;
+         break;
+       }  
+     }
+    return *bp;                        
+   }
+
+
+
+
+/*Compares two oc_huff_entry structures by their bit patterns.
+  _c1: The first entry to compare.
+  _c2: The second entry to compare.
+  Return: <0 if _c1<_c2, >0 if _c1>_c2.*/
+static int huff_entry_cmp(const void *_c1,const void *_c2){
+  ogg_uint32_t b1;
+  ogg_uint32_t b2;
+  b1=((const oc_huff_entry *)_c1)->pattern;
+  b2=((const oc_huff_entry *)_c2)->pattern;
+  return b1<b2?-1:b1>b2?1:0;
+}
+
+/*Encodes a description of the given Huffman tables.
+  Although the codes are stored in the encoder as flat arrays, in the bit
+   stream and in the decoder they are structured as a tree.
+  This function recovers the tree structure from the flat array and then
+   writes it out.
+  Note that the codes MUST form a Huffman code, and not merely a prefix-free
+   code, since the binary tree is assumed to be full.
+  _opb:   The buffer to store the tree in.
+  _codes: The Huffman tables to pack.
+  Return: 0 on success, or a negative value if one of the given Huffman tables
+   does not form a full, prefix-free code.*/
+
+// used void oggpackB_write(oggpack_buffer *b,unsigned long value,int bits) from theora/libogg-1.1.1/src/bitwise.c
+// it is probably optimized so it will be a good idea to use the library, but now - just some shortcuts.
+//   int theora_write_bits (char * buf, // buffer
+//                          int * bp,   // pointer to bit pointer
+//                          int data,   // data to write
+//                          int nb)     // number of bits to write
+
+   
+//int oc_huff_codes_pack(oggpack_buffer *_opb,
+int oc_huff_codes_pack(char *buf, int* bp,
+ const theora_huff_code _codes[OC_NHUFFMAN_TABLES][OC_NDCT_TOKENS]){
+  int i;
+  for(i=0;i<OC_NHUFFMAN_TABLES;i++){
+    oc_huff_entry entries[OC_NDCT_TOKENS];
+    int           bpos;
+    int           maxlen;
+    int           mask;
+    int           j;
+    /*First, find the maximum code length so we can align all the bit
+       patterns.*/
+    maxlen=_codes[i][0].nbits;
+    for(j=1;j<OC_NDCT_TOKENS;j++){
+      maxlen=OC_MAXI(_codes[i][j].nbits,maxlen);
+    }
+    mask=(1<<maxlen)-1;
+    /*Copy over the codes into our temporary workspace.
+      The bit patterns are aligned, and the original entry each code is from
+       is stored as well.*/
+    for(j=0;j<OC_NDCT_TOKENS;j++){
+      entries[j].shift=maxlen-_codes[i][j].nbits;
+      entries[j].pattern=_codes[i][j].pattern<<entries[j].shift&mask;
+      entries[j].token=j;
+    }
+    /*Sort the codes into ascending order.
+      This is the order the leaves of the tree will be traversed.*/
+    qsort(entries,OC_NDCT_TOKENS,sizeof(entries[0]),huff_entry_cmp);
+    /*For each leaf of the tree:*/
+    bpos=maxlen;
+    for(j=0;j<OC_NDCT_TOKENS;j++){
+      int bit;
+      /*If this code has any bits at all.*/
+      if(entries[j].shift<maxlen){
+        /*Descend into the tree, writing a bit for each branch.*/
+//        for(;bpos>entries[j].shift;bpos--)oggpackB_write(_opb,0,1);
+        for(;bpos>entries[j].shift;bpos--)theora_write_bits(buf,bp,0,1);
+        
+        /*Mark this as a leaf node, and write its value.*/
+//        oggpackB_write(_opb,1,1);
+        theora_write_bits(buf,bp,1,1);
+//        oggpackB_write(_opb,entries[j].token,5);
+        theora_write_bits(buf,bp,entries[j].token,5);
+        /*For each 1 branch we've descended, back up the tree until we reach a
+           0 branch.*/
+        bit=1<<bpos;
+        for(;entries[j].pattern&bit;bpos++)bit<<=1;
+        /*Validate the code.*/
+        if(j+1<OC_NDCT_TOKENS){
+          mask=~(bit-1)<<1;
+          /*The next entry should have a 1 bit where we had a 0, and should
+             match our code above that bit.
+            This verifies both fullness and prefix-freeness simultaneously.*/
+          if(!(entries[j+1].pattern&bit)||
+           (entries[j].pattern&mask)!=(entries[j+1].pattern&mask)){
+            return OC_EINVAL;
+          }
+        }
+        /*If there are no more codes, we should have ascended back to the top
+           of the tree.*/
+        else if(bpos<maxlen)return OC_EINVAL;
+      }
+    }
+  }
+  return 0;
+}
+
+
+// code assumes little endian
+int ogg_page      (ogg_header_t *    ogg_header, // pointer to the header data (returns - header length in bytes)
+                            char     flags,
+                            u_int64_t granule,
+                            u_int32_t stream_serial,
+                            int      page,       // page
+                            int      num_packets, // number of packets in the page
+                   len_data_t *      packets) {
+     int i,n,nn,r;
+     u_int32_t crc_reg;
+     char * c_header= (char *) ogg_header;
+     memcpy (ogg_header->OggS,oggs_string,4);
+     ogg_header->version=        0;
+     ogg_header->serial[0]=      stream_serial & 0xff;
+     ogg_header->serial[1]=      (stream_serial>> 8) & 0xff;
+     ogg_header->serial[2]=      (stream_serial>>16) & 0xff;
+     ogg_header->serial[3]=      (stream_serial>>24) & 0xff;
+     ogg_header->flags=          flags;
+     ogg_header->granule[0]=     granule & 0xff;
+     ogg_header->granule[1]=     (granule>> 8) & 0xff;
+     ogg_header->granule[2]=     (granule>>16) & 0xff;
+     ogg_header->granule[3]=     (granule>>24) & 0xff;
+     ogg_header->granule[4]=     (granule>>32) & 0xff;
+     ogg_header->granule[5]=     (granule>>40) & 0xff;
+     ogg_header->granule[6]=     (granule>>48) & 0xff;
+     ogg_header->granule[7]=     (granule>>56) & 0xff;
+     ogg_header->page[0]=        page & 0xff;
+     ogg_header->page[1]=        (page>> 8) & 0xff;
+     ogg_header->page[2]=        (page>>16) & 0xff;
+     ogg_header->page[3]=        (page>>24) & 0xff;
+     ogg_header->crc[0]=         0;
+     ogg_header->crc[1]=         0;
+     ogg_header->crc[2]=         0;
+     ogg_header->crc[3]=         0;
+// first pass - just fill lacing values/number of segments
+     n=0;
+     for (i=0;i<num_packets; i++) {
+        nn=(packets[i].len/255);
+        r= packets[i].len - 255* nn;
+        nn+=n;
+        if (nn>254)
+            return -1;
+        for (;n<nn;n++)
+            ogg_header->lacing_values[n]=255;
+        ogg_header->lacing_values[n++]=r;
+     }
+     ogg_header->num_segm=       n;
+     // second pass - calculate the crc     
+     crc_reg=0;
+     for (i=0;i<(27+c_header[26]);i++) 
+        crc_reg=(crc_reg<<8)^crc_lookup[((crc_reg >> 24)^c_header[i])&0xff];
+     for (i=0;i<num_packets; i++) {
+       for (n=0;n<packets[i].len;n++) 
+            crc_reg=(crc_reg<<8)^crc_lookup[((crc_reg >> 24)^packets[i].data[n])&0xff];
+     }
+     ogg_header->crc[0]=        crc_reg & 0xff;
+     ogg_header->crc[1]=        (crc_reg>> 8) & 0xff;
+     ogg_header->crc[2]=        (crc_reg>>16) & 0xff;
+     ogg_header->crc[3]=        (crc_reg>>24) & 0xff;
+     return (27+c_header[26]);
+}
+
+// similar to above, but dedicated to the frame data.
+// There could be 2 types
+// - first page of a frame (packet) then frame header will be attached and bit-combined with the frame
+// - continuation  page (flags bit 0 should be set) - then no frame header will be added to the data
+// currently there could not be two frames (packets) on one page
+int ogg_frame_page      (ogg_header_t *    ogg_header,      // pointer to the header data (returns - header length in bytes)
+                            char           flags,           // +1 - continuation, +4 - last (+2 - first)
+                            int            maxpage,         // maximal page size (w/o ogg header)
+                            u_int64_t      granule,         // 
+                            u_int32_t      stream_serial,   //
+                            int            page,            // page
+                            len_data_t     frame_header,    // not used if (flags & 1). frame_header.len is measured in bits, not bytes!
+                            int          * len,             // pointer frame data length (will modify - if non-zero - need continuation)
+                            u_int8_t    ** frame_datap)     // pointer to pointer to an array with frame data
+                                                            // if it is not continuation data is bit-aligned to be combined with frame_header
+                                                            // first word of frame data will be modified - OR-ed with the last one from
+                                                            // the frame_header
+                   
+   {
+     int i,l,n,nn,r;
+     int dl;
+//     unsigned char cmask[4];
+//     u_int32_t  *mask = (u_int32_t *) cmask;
+     u_int8_t   * frame_data = frame_datap[0];
+     u_int32_t  mask;
+     u_int8_t  *cmask= (u_int8_t  *) &mask;
+     u_int32_t  *fh32=  (u_int32_t *) frame_header.data;
+     u_int32_t crc_reg;
+     u_int32_t  *fd32=  (u_int32_t *) frame_data;
+     char * c_header= (char *) ogg_header;
+     u_int64_t  granule0=0;
+//quick fix to modify (up to) last 31 bits of header (not first data word)
+     int        skip_first_data=0;
+D(fprintf(stderr,"ogg_frame_page: flags=%d, page= %d, frame_header.len=%d, len=%d\n",flags, page, frame_header.len, len[0]));
+     memcpy (ogg_header->OggS,oggs_string,4);
+     ogg_header->version=        0;
+     ogg_header->serial[0]=      stream_serial & 0xff;
+     ogg_header->serial[1]=      (stream_serial>> 8) & 0xff;
+     ogg_header->serial[2]=      (stream_serial>>16) & 0xff;
+     ogg_header->serial[3]=      (stream_serial>>24) & 0xff;
+     ogg_header->page[0]=        page & 0xff;
+     ogg_header->page[1]=        (page>> 8) & 0xff;
+     ogg_header->page[2]=        (page>>16) & 0xff;
+     ogg_header->page[3]=        (page>>24) & 0xff;
+     ogg_header->crc[0]=         0;
+     ogg_header->crc[1]=         0;
+     ogg_header->crc[2]=         0;
+     ogg_header->crc[3]=         0;
+
+
+
+    // combine frame_data[0] with the tail of frame_header if needed
+     if ((flags & 1) == 0) { //first page in packet
+      if ((i=(frame_header.len & 0x1f))) {
+        skip_first_data=4;
+        n=0;
+        mask=0;
+        while (i>=8) {cmask[n++]=0xff; i-=8;}
+        cmask[n]=(0xff00 >> i) & 0xff;
+ D(fprintf(stderr,"ogg_frame_page: 0 frame_header.data[0]=0x%x,frame_header.data[1]=0x%x,frame_header.data[2]=0x%x,frame_header.data[3]=0x%x\n",
+ frame_header.data[0],frame_header.data[1],frame_header.data[2],frame_header.data[3]));
+
+D(fprintf(stderr,"ogg_frame_page: 1 mask=0x%x, fd32[0]=0x%x, fh32[frame_header.len>>5]=0x%x\n",mask,fd32[0],fh32[frame_header.len>>5]));
+// modifying header, not data (was a problem with mmap)
+#if 0
+       fd32[0]^= (fd32[0]^fh32[frame_header.len>>5]) & mask;
+D(fprintf(stderr,"ogg_frame_page: 2 mask=0x%x, fd32[0]=0x%x, fh32[frame_header.len>>5]=0x%x\n",mask,fd32[0],fh32[frame_header.len>>5]));
+#else
+       fh32[frame_header.len>>5]^=(fd32[0]^fh32[frame_header.len>>5]) & ~mask;
+#endif
+      }
+     }
+     
+// see if everything will fit on this page
+     l=((flags & 1) == 0)?((frame_header.len>>3)&(~3)):0; // add frame header to the first page in a frame
+     if ((l+len[0])> maxpage) {
+       nn= maxpage/255;
+       dl= 255*nn;
+       nn--;
+       r=255;
+       granule0=~0ULL;
+       ogg_header->flags= flags & 3; //remove "last page" flag
+D(fprintf(stderr,"*"));
+     } else {
+       granule0=granule;
+D(fprintf(stderr," granule0=0x%llx\n",granule0));
+       dl=l+len[0];
+       nn=dl/255;
+       r= dl-255*nn;
+       ogg_header->flags=          flags;
+     }
+//D(fprintf(stderr," granule0=0x%llx\n",granule0));
+     frame_datap[0]+=(dl-l);
+     ogg_header->granule[0]=     granule0 & 0xff;
+     ogg_header->granule[1]=     (granule0>> 8) & 0xff;
+     ogg_header->granule[2]=     (granule0>>16) & 0xff;
+     ogg_header->granule[3]=     (granule0>>24) & 0xff;
+     ogg_header->granule[4]=     (granule0>>32) & 0xff;
+     ogg_header->granule[5]=     (granule0>>40) & 0xff;
+     ogg_header->granule[6]=     (granule0>>48) & 0xff;
+     ogg_header->granule[7]=     (granule0>>56) & 0xff;
+
+
+// first pass - just fill lacing values/number of segments
+D(fprintf(stderr,"            ogg_frame_page: l=%d, len= %d\n",l, len[0]));
+//     if (nn>254) return -1;
+     for (n=0;n<nn;n++) ogg_header->lacing_values[n]=255;
+     ogg_header->lacing_values[n++]=r;
+     ogg_header->num_segm=  n;
+
+
+     
+// second pass - calculate the crc
+     crc_reg=0;
+     for (i=0;i<(27+c_header[26]);i++) crc_reg=(crc_reg<<8)^crc_lookup[((crc_reg >> 24)^c_header[i])&0xff];
+     if ((l+skip_first_data)>0) for (n=0;n<(l+skip_first_data);n++) crc_reg=(crc_reg<<8)^crc_lookup[((crc_reg >> 24)^frame_header.data[n])&0xff];
+     for (n=skip_first_data;n<(dl-l);n++)        crc_reg=(crc_reg<<8)^crc_lookup[((crc_reg >> 24)^frame_data[n])&0xff];
+     
+D(fprintf(stderr,"            ogg_frame_page: l=%d, (dl-l)= %d, n=0x%x\n",l, (dl-l),n));
+D(for (i=0;i<32;i++) fprintf(stderr," %x",frame_data[i]));
+D(fprintf(stderr,"\n"));
+    
+D(for (i=-32;i<0;i++) fprintf(stderr," %x",frame_data[(dl-l)+i]));
+D(fprintf(stderr,"\n"));
+     
+     ogg_header->crc[0]=        crc_reg & 0xff;
+     ogg_header->crc[1]=        (crc_reg>> 8) & 0xff;
+     ogg_header->crc[2]=        (crc_reg>>16) & 0xff;
+     ogg_header->crc[3]=        (crc_reg>>24) & 0xff;
+     len[0]-=(dl-l);
+     return (27+c_header[26]);
+   }
+
+
+
+
+//static const char theora_string[6]={0x74,0x68,0x65,0x6f,0x72,0x61};
+   int theora_identification (char *buf,  // returns length, buf should be big enough - 42 bytes
+                              int   fmbw, // width in macroblocks
+                              int   fmbh, // height in macroblocks
+                              int   frn, // frame rate nominator ( in 1/1000000)
+                              int   frd, // frame rate denominator (1000000)
+                              int   nobr, // nominal bit rate (-1 - undefined?)
+                              int   qual, // relative quality (was 0x10)
+                              int   kfgshift) // number of bits in granule used for number of i-frames
+   {
+     int bp;
+     buf[ 0]=0x80;
+     memcpy (buf+1,theora_string,6);
+     buf[ 7]=0x03;
+     buf[ 8]=0x02;
+     buf[ 9]=0x00;
+     buf[10]=(fmbw >> 8)  & 0xff;
+     buf[11]=fmbw &         0xff;
+     buf[12]=(fmbh >> 8)  & 0xff;
+     buf[13]=fmbh &         0xff;
+     buf[14]=(fmbw >> 12) & 0xff;
+     buf[15]=(fmbw >>  4) & 0xff;
+     buf[16]=(fmbw <<  4) & 0xff;
+     
+     buf[17]=(fmbh >> 12) & 0xff;
+     buf[18]=(fmbh >>  4) & 0xff;
+     buf[19]=(fmbh <<  4) & 0xff;
+     buf[20]=0x00;
+     buf[21]=0x00;
+     buf[22]=(frn >> 24) &0xff;
+     buf[23]=(frn >> 16) &0xff;
+     buf[24]=(frn >>  8) &0xff;
+     buf[25]= frn        &0xff;
+     buf[26]=(frd >> 24) &0xff;
+     buf[27]=(frd >> 16) &0xff;
+     buf[28]=(frd >>  8) &0xff;
+     buf[29]= frd        &0xff;
+     buf[30]= 0; //PARN - 3 bytes
+     buf[31]= 0;
+     buf[32]= 0;
+     buf[33]= 0; //PARD - 3 bytes
+     buf[34]= 0;
+     buf[35]= 0;
+     buf[36]= 0; // color space - "undefined"
+     buf[37]=(nobr >> 16) &0xff;
+     buf[38]=(nobr >>  8) &0xff;
+     buf[39]= nobr        &0xff;
+     bp=40 << 3; // bit pointer
+     theora_write_bits (buf, &bp, qual,6);
+     theora_write_bits (buf, &bp, kfgshift,5);
+     theora_write_bits (buf, &bp, 0,2); // pixel format 4:2:0
+     theora_write_bits (buf, &bp, 0,3); // reserved bits
+     return 42; // length
+   }
+                              
+   int theora_comments (char        *buf,    // returns length, buf should be big enough - ?? bytes
+                        int          buflen,  // buffer size (returns -1 if fails to fit)
+                        const char  *vendor, // Null-terminated string (was "Xiph.Org libTheora I 20040317 3 2 0\0")
+                        int          nuser,   // number of user comments
+                        const char **user)
+   {
+     int b,len,i;
+     if (buflen<15) return -1;
+     buf[ 0]=0x81;
+     memcpy (buf+1,theora_string,6);
+     b=7;
+     len=0; if (vendor) len = strlen(vendor);
+     buf[b++]= len        &0xff; // here - little endian
+     buf[b++]=(len >>  8) &0xff;
+     buf[b++]=(len >> 16) &0xff;
+     buf[b++]=(len >> 24) &0xff;
+     if (len>0) {
+       if (buflen<(b+len+4)) return -1;
+       memcpy (&buf[b],vendor,len);
+       b+=len;
+     }
+     buf[b++]= nuser        &0xff; // here - little endian
+     buf[b++]=(nuser >>  8) &0xff;
+     buf[b++]=(nuser >> 16) &0xff;
+     buf[b++]=(nuser >> 24) &0xff;
+     for (i=0;i<nuser;i++) {
+       len=strlen(user[i]);
+       if (buflen<(b+len+4)) return -1;
+       buf[b++]= len        &0xff; // here - little endian
+       buf[b++]=(len >>  8) &0xff;
+       buf[b++]=(len >> 16) &0xff;
+       buf[b++]=(len >> 24) &0xff;
+       memcpy (&buf[b],user[i],len);
+       b+=len;
+     }
+//  D(fprintf(stderr, "theora_comments b=%d\n",b));
+    return b;    
+   }
+
+   int theora_setup (char       *buf,    // returns length, buf should be big enough - ?? bytes
+                     int         buflen,  // buffer size (returns -1 if fails to fit)
+// the next pointers will likely point to constant tables, the same ones should be used to program FPGA internal tables                     
+                     const int  *lflims,  // if null - skip  alltogether, not null - 5 assumed bits/value
+                     const int  *acscale, // will encode 10bits/item
+                     const int  *dcscale, // will encode 10bits/item
+                     const int  bms[][64]    // array of 3 BMS tables
+                        )
+   {
+     int bp,i,bmi;
+     buf[ 0]=0x82;
+     memcpy (buf+1,theora_string,6);
+     bp=7<<3;
+// Here should go the loop filters - try to skip them alltogether as current FPGAa implementation does not support them
+    if (lflims) {
+     theora_write_bits (buf, &bp, 5,3); // loop filter values are 5 bit long
+     for (i=0;i<64;i++)  theora_write_bits (buf, &bp, lflims[i],5);
+    } else theora_write_bits (buf, &bp, 0,3); // loop filter values are 0 length (so all zeros)
+// now put ACSCALE table
+     theora_write_bits (buf, &bp, 9,4); // ACSCALE table will have 10 bits
+     for (i=0;i<64;i++) theora_write_bits (buf, &bp, acscale[i],10);
+// now put DCSCALE table
+     theora_write_bits (buf, &bp, 9,4); // DCSCALE table will have 10 bits
+     for (i=0;i<64;i++) theora_write_bits (buf, &bp, dcscale[i],10);
+// BMS - counting on standartd VP3 set of 3 base matrices
+     theora_write_bits (buf, &bp, 2,9); // NBMS=3
+     for (bmi=0;bmi<3;bmi++) for (i=0;i<64;i++) theora_write_bits (buf, &bp, bms[bmi][i],8);
+// next tables:
+//NQRS=   {{1,1,1},{1,1,1}}
+//QRSIZES={{63},{63},{63},{63},{63},{63}}
+//QRBMIS{{{0,0},{1,1},{1,1}},{{2,2},{2,2},{2,2}}}
+// Maybe just preencode and put 37 bits?
+     theora_write_bits (buf, &bp,  0,2); // QRBMIS[0][0][0]=0
+     theora_write_bits (buf, &bp, 62,6); // QRSIZES[0][0][0]=63
+     theora_write_bits (buf, &bp,  0,2); // QRBMIS[0][0][1]=0
+     theora_write_bits (buf, &bp,  1,1); // NEWQR=1
+     theora_write_bits (buf, &bp,  1,2); // QRBMIS[0][1][0]=1
+     theora_write_bits (buf, &bp, 62,6); // QRSIZES[0][1][0]=63
+     theora_write_bits (buf, &bp,  1,2); // QRBMIS[0][1][1]=1
+     theora_write_bits (buf, &bp,  0,1); // NEWQR=0:
+                                         //  NQRS[0][2]=NQRS[0][1]=1
+                                         //  QRSIZES[0][2]=QRSIZES[0][1]={63}
+                                         //  QRBMIS[0][2] = QRBMIS[0][1]={1,1}
+     theora_write_bits (buf, &bp,  1,1); // NEWQR=1
+     theora_write_bits (buf, &bp,  2,2); // QRBMIS[1][0][0]=2
+     theora_write_bits (buf, &bp, 62,6); // QRSIZES[1][0][0]=63
+     theora_write_bits (buf, &bp,  2,2); // QRBMIS[1][0][1]=2
+     theora_write_bits (buf, &bp,  0,1); // NEWQR=0
+     theora_write_bits (buf, &bp,  0,1); // (qti>0), so write RPQR=0
+                                         //  NQRS[1][1]=NQRS[1][0]=1
+                                         //  QRSIZES[1][1]=QRSIZES[1][0]={63}
+                                         //  QRBMIS [1][1]=QRBMIS [1][0]={2,2}
+     theora_write_bits (buf, &bp,  0,1); // NEWQR=0
+     theora_write_bits (buf, &bp,  0,1); // (qti>0), so write RPQR=0
+                                         //  NQRS[2][1]=NQRS[1][1]=1
+                                         //  QRSIZES[2][1]=QRSIZES[1][1]={63}
+                                         //  QRBMIS [2][1]=QRBMIS [1][1]={2,2}
+// next - huffman tables                                          
+     if ((i=oc_huff_codes_pack(buf, &bp, OC_VP31_HUFF_CODES))<0) return i;
+// D(fprintf(stderr, "setup bits=%d\n",bp));
+     return (bp>>3)+((bp & 7)? 1:0);
+
+   }
+
+
+//filling out FPGA tables
+  void fill_FPGA_qtable (u_int32_t *table,
+                         int       inter,
+                         int       color,
+                         int       qindex_dc, // always the same in a frame
+                         int       qindex_ac, // may be different if it is a second qi in a frame
+                         int       sharpness)  // 0..2 - common for all q
+{
+     int       zbin_index_dc= (sharpness<<1) | (theora_DCSCALE[qindex_dc]>50)?1:0;// index of zero bin/rounding table to use (table is separate)
+     int       zbin_index_ac= (sharpness<<1) | (theora_DCSCALE[qindex_ac]>50)?1:0;// index of zero bin/rounding table to use (table is separate)
+     int i;
+     int bmi=inter?2:(color?1:0);
+     
+     int mindc= inter? 32 :16;
+     int minac= inter? 16 : 8;
+     int dqcoef  = (((((theora_BMS[bmi][0] * theora_DCSCALE[qindex_dc])/100)<<2) > mindc)?
+         (((theora_BMS[bmi][0] * theora_DCSCALE[qindex_dc])/100)<<2): mindc) & 0xfff;
+     int qcoef   = (524288/dqcoef) & 0xffff;
+ D(fprintf(stderr,"bmi=%d, qindex_dc=%d, qindex_ac=%d, sharpness=%d, zbin_index_dc=%d, zbin_index_ac=%d\n",bmi, qindex_dc, qindex_ac, sharpness,
+             zbin_index_dc,zbin_index_ac));
+     table[0]=(zbin_index_dc<<28) | (dqcoef<<16) | qcoef;
+//  D(fprintf(stderr,"%x/%x=%x ",dqcoef,(524288/dqcoef),table[0]));
+
+// FPGA Quantization table is transposed (at least for now - wil fix later)
+     for (i=1; i<64; i=i+1) {
+       dqcoef  = (((((theora_BMS[bmi][i] * theora_ACSCALE[qindex_ac])/100)<<2) > minac)?
+        (((theora_BMS[bmi][i] * theora_ACSCALE[qindex_ac])/100)<<2): minac) & 0xfff;
+       qcoef   = (524288/dqcoef) & 0xffff;
+       table[i]=(zbin_index_ac<<28) | (dqcoef<<16) | qcoef;
+
+//Changed back - transposed in FPGA
+//       table[((i>>3) & 0x7) | ((i << 3) & 0x38)]=(zbin_index_ac<<28) | (dqcoef<<16) | qcoef;
+//   D(fprintf(stderr,"%x/%x=%x ",dqcoef,(524288/dqcoef),table[i]));
+     }
+   D(fprintf(stderr,"\n"));
+}
+  void fill_FPGA_qtables (
+     u_int32_t  tables[512],
+     int  sharpness,
+     int  intra_y_qi_hi,   // index in DC_Scale/AC_Scale tables, intra frame, luma
+     int  intra_c_qi_hi,   // index in DC_Scale/AC_Scale tables, intra frame, chroma
+     int  inter_y_qi_hi,   // index in DC_Scale/AC_Scale tables, inter frame, luma
+     int  inter_c_qi_hi,   // index in DC_Scale/AC_Scale tables, inter frame, chroma
+
+     int  intra_y_qi_lo,   // index in DC_Scale/AC_Scale tables, intra frame, luma
+     int  intra_c_qi_lo,   // index in DC_Scale/AC_Scale tables, intra frame, chroma
+     int  inter_y_qi_lo,   // index in DC_Scale/AC_Scale tables, inter frame, luma
+     int  inter_c_qi_lo)   // index in DC_Scale/AC_Scale tables, inter frame, chroma
+     {
+       fill_FPGA_qtable (&tables[  0], 0, 0, intra_y_qi_hi, intra_y_qi_hi, sharpness);
+       fill_FPGA_qtable (&tables[128], 0, 1, intra_c_qi_hi, intra_c_qi_hi, sharpness);
+       fill_FPGA_qtable (&tables[256], 1, 0, inter_y_qi_hi, inter_y_qi_hi, sharpness);
+       fill_FPGA_qtable (&tables[384], 1, 1, inter_c_qi_hi, inter_c_qi_hi, sharpness);
+       fill_FPGA_qtable (&tables[ 64], 0, 0, intra_y_qi_hi, intra_y_qi_lo, sharpness);
+       fill_FPGA_qtable (&tables[192], 0, 1, intra_c_qi_hi, intra_c_qi_lo, sharpness);
+       fill_FPGA_qtable (&tables[320], 1, 0, inter_y_qi_hi, inter_y_qi_lo, sharpness);
+       fill_FPGA_qtable (&tables[448], 1, 1, inter_c_qi_hi, inter_c_qi_lo, sharpness);
+     }
+  // {len[3:0],data[13:0]} - data is MSB aligned
+  int fill_FPGA_htables (u_int16_t hti  [12],
+                          u_int16_t hti30[16],
+                          u_int32_t htable[1024],
+                          int       pre_ht[12],
+                          int       pre_ht30[6])
+  {
+     int i,j,k,l,d;                       
+     for (i=0; i<12; i++) hti[i]=pre_ht30[pre_ht[i]];
+     for (i=0; i<16; i++) hti30[i]=7;             // unused
+     for (i=0; i< 6; i++) hti30[pre_ht30[i]] = i; // fill just needed
+     for (i=0; i< 5; i++) for (j=0;j<6;j++) for (k=0;k<32;k++) {
+       l=OC_VP31_HUFF_CODES[(i<<4)+pre_ht30[j]][k].nbits;
+       if (l>14) {fprintf(stderr,"huffman code too long %d > 14 in table %d, token %d\n",
+                  l, (i<<4)+j,k ); return -1;}
+       d=OC_VP31_HUFF_CODES[(i<<4)+pre_ht30[j]][k].pattern  << (14-l);  // only - up to 14 bits long !!!
+       htable[i*192 + (j<<5) +k] = (d & 0x3fff) | (l << 14);
+     }      
+    return 0;
+  }
+           
+
+ // fwrites data to stream, until all sent
+int fwrite_all(FILE *  stream, char * data, int len) {
+    char *cp= data;
+    int   l=0;
+    while (len>0) {
+        if ((l = fwrite(cp, 1,len, stream))<0) return l;
+        len -= l;
+        cp  += l;
+    }  
+    return (cp-data);  
+}
+
+int makeOggTheora(u_int32_t * ccam_dma_index, // will be mmaped array in the camera
+                      u_int8_t  * ccam_dma,       // will be mmaped array in the camera (char array)
+                      FILE *      movie_file,
+                      int         page_size,      // maximal; page size to use
+                      len_data_t  packets[6],     // 0 - identification
+                                                  // 1 - comment
+                                                  // 2 - setup
+                                                  // 3 - frame - intra (.len - in bits, not bytes!)
+                                                  // 4 - frame - inter/full
+                                                  // 5 - frame - inter/mapped
+                      u_int32_t   stream_serial,
+                      int         kfgshiftm       // number of bits in granule used for number of i-frames
+                      ) {
+    
+      ogg_header_t header;
+      int          header_length, fw;
+      u_int64_t    granule=0;
+      u_int64_t    granule_mask=(1<<kfgshiftm)-1;
+      //u_int64_t    next_granule=0;
+      u_int8_t   * dp;
+      u_int8_t   * dp_prev;
+      int          nframe=0;
+      int          frame_start=0;   // in bytes
+      int          next_frame_start;// in bytes
+      int          frame_length;
+      //int          frame_length_written;
+      int          frame_header_length;   // frame header lengh truncated to 32-bit words (the rest is combined with frame data)
+      int          frame_type;      // 0 - intra, 1 - inter/full, 2 - inter/partial
+      int          page=0;
+      int          last_page_flags;
+      int          overlapped_header; // 0/4 - if "4" then bits from the first word of data are already copied to the header
+      int          first_frame=1;
+// first make and send out first two pages (second - with 2 packets)
+    D(fprintf(stderr,"makeOggTheora: stream_serial=0x%x, kfgshiftm=0x%x\n",stream_serial,kfgshiftm));
+
+    header_length= ogg_page (&header, 2, 0, stream_serial, page++, 1, &packets[0]); //42
+    if (header_length<0) return header_length-1000;
+    if ((fw= fwrite_all(movie_file, (char *) &header, header_length))<0) {
+        fprintf(stderr,"error writing output data1 - error = %d (%s)\n",
+                                                         errno,strerror(errno)); 
+        return fw;
+    }
+    if ((fw= fwrite_all(movie_file, packets[0].data, packets[0].len))<0) {
+        fprintf(stderr,"error writing output data2 - error = %d (%s)\n",
+                                                         errno,strerror(errno)); 
+        return fw;
+    }
+    header_length= ogg_page (&header, 0, 0, stream_serial, page++, 2, &packets[1]);
+
+    if (header_length<0) 
+        return header_length-2000;
+    
+    if ((fw= fwrite_all(movie_file, (char *) &header, header_length))<0) {
+        fprintf(stderr,"error writing output data3 - error = %d (%s)\n",
+                                                         errno,strerror(errno)); 
+        return fw;
+    }
+    if ((fw= fwrite_all(movie_file, packets[1].data, packets[1].len))<0) {
+        fprintf(stderr,"error writing output data4 - error = %d (%s)\n",
+                        errno, strerror(errno)); 
+        return fw;
+    }
+    if ((fw= fwrite_all(movie_file, packets[2].data, packets[2].len))<0) {
+        fprintf(stderr,"error writing output data5 - error = %d (%s)\n",
+                        errno,strerror(errno)); 
+        return fw;
+    }
+    // now frames
+    // what kind of an abort command is ths?
+    while (ccam_dma_index[nframe]!=0xffffffff) {
+        D(fprintf(stderr,"++++++++++++++++++++makeOggTheora: ccam_dma_index[%d]=%d(0x%x)\n",nframe,ccam_dma_index[nframe],ccam_dma_index[nframe]));
+      
+        frame_length=(ccam_dma_index[nframe] & 0xfffffff)-frame_start;
+        next_frame_start=((ccam_dma_index[nframe] & 0xfffffff)+63) & (~0x1f);
+        frame_type=(ccam_dma_index[nframe]>>28) & 3;
+#if 0
+        frame_header_length=  (packets[3+frame_type].len>>3)& (~3);
+#else
+        frame_header_length=  ((packets[3+frame_type].len+31)>>3)& (~3);
+        overlapped_header=    (packets[3+frame_type].len & 31)?4:0;
+#endif
+        last_page_flags= (ccam_dma_index[nframe+1]==0xffffffff)?4:0;
+        //next_granule= (granule | (frame_type?0:granule_mask))+1;
+        //granule= (granule | (frame_type?0:granule_mask))+1;
+        dp=&ccam_dma[frame_start];
+        if (first_frame) {
+            first_frame=0;
+        } else if (frame_type==INTRA){
+            //granule= (granule | ((frame_type==0)?granule_mask:0))+1;
+            granule=(granule+ (((granule&granule_mask)+1)<<kfgshiftm)) & (~granule_mask);
+        } else {
+            granule=(granule & (~granule_mask)) |  ((granule+1) &granule_mask);
+        }
+        D(fprintf(stderr,"********************makeOggTheora: nframe=%d, frame_length=%d (0x%x), next_frame_start=%d(0x%x), frame_type=%d\n",
+        nframe,frame_length,frame_length,next_frame_start,next_frame_start,frame_type));
+
+        dp_prev=&ccam_dma[frame_start];
+
+        header_length= ogg_frame_page (&header,                  // pointer to the header data (returns - header length in bytes)
+                                        last_page_flags,         // +1 - continuation, +4 - last (+2 - first)
+                                                                 // "last" will be masked out if needed
+                                        page_size,
+                                        granule,
+                                        stream_serial,
+                                        page++,
+                                        packets[3+frame_type],  // not used if (flags & 1). frame_header.len is measured in bits, not bytes!
+                                        &frame_length,          // frame data length
+                                        &dp);                   // pointer to array with frame data (bytes)
+            
+ D(fprintf(stderr,"----header_length=%d, (dp-dp_prev)=0x%x, dp[0]=%x, dp_prev[0]=%x\n", header_length,(int) (dp-dp_prev),dp[0],dp_prev[0]));
+ D(fprintf(stderr,"----header_length=%d, (dp-dp_prev)=0x%x, dp[1]=%x, dp_prev[1]=%x\n", header_length,(int) (dp-dp_prev),dp[1],dp_prev[1]));
+ D(fprintf(stderr,"----header_length=%d, (dp-dp_prev)=0x%x, dp[2]=%x, dp_prev[2]=%x\n", header_length,(int) (dp-dp_prev),dp[2],dp_prev[2]));
+
+        if (header_length<0) 
+            return header_length-3000;
+        // write to output stream first (or only) page of a frame
+        if ((fw= fwrite_all(movie_file, (char *) &header, header_length))<0) {
+            fprintf(stderr,"error writing output data6 - error = %d (%s)\n",
+                            errno,strerror(errno)); 
+            return fw;
+        }
+        if ((fw= fwrite_all(movie_file, packets[3+frame_type].data, frame_header_length))<0) {
+            fprintf(stderr,"error writing output data7 - error = %d (%s)\n",
+                            errno,strerror(errno)); 
+            return fw;
+        }
+        if ((fw= fwrite_all(movie_file, dp_prev+overlapped_header, (int) (dp-dp_prev-overlapped_header)))<0) {
+            fprintf(stderr,"error writing output data8 - error = %d (%s)\n",
+                            errno,strerror(errno)); 
+            return fw;
+        }
+
+        // see if needed more pages
+        while (frame_length>0) {
+            dp_prev=dp;
+            header_length= ogg_frame_page (&header,               // [1]
+                                           last_page_flags,       // [2]
+                                           page_size,
+                                           granule,
+                                           stream_serial,
+                                           page++,
+                                           packets[3+frame_type], // [3]
+                                           &frame_length,         // [4]
+                                           &dp                    // [5]
+                                          );
+        /*
+         [1] pointer to the header data
+             (returns - header length in bytes)
+         [2] +1 - continuation, +4 - last (+2 - first)
+             "last" will be masked out if needed
+         [3]  not used if (flags & 1). 
+              frame_header.len is measured in bits, not bytes!
+         [4]  frame data length
+         [5]  pointer to array with frame data(bytes)
+        */
+
+ D(fprintf(stderr,"----header_length=%d, (dp-dp_prev)=0x%x, dp[0]=%x, dp_prev[0]=%x\n", header_length,(int) (dp-dp_prev),dp[0],dp_prev[0]));
+ D(fprintf(stderr,"----header_length=%d, (dp-dp_prev)=0x%x, dp[1]=%x, dp_prev[1]=%x\n", header_length,(int) (dp-dp_prev),dp[1],dp_prev[1]));
+ D(fprintf(stderr,"----header_length=%d, (dp-dp_prev)=0x%x, dp[2]=%x, dp_prev[2]=%x\n", header_length,(int) (dp-dp_prev),dp[2],dp_prev[2]));
+
+            // write to output stream other pages of a frame
+            if ((fw= fwrite_all(movie_file, (char *) &header, header_length))<0) {
+                fprintf(stderr,"error writing output data9 - error = %d (%s)\n",
+                                errno,strerror(errno)); 
+                return fw;
+            }
+            if ((fw= fwrite_all(movie_file, dp_prev, (int) (dp-dp_prev)))<0){
+                fprintf(stderr,"error writing output data10 - error = %d (%s)\n",
+                                errno,strerror(errno)); 
+                return fw;
+            }                               
+        }
+        //granule= (granule | (frame_type?0:granule_mask))+1;
+        nframe++;
+        frame_start=next_frame_start;
+    }
+    return 0;
+}
+
+                           
+int oggtheora_prepare (const char *headers_filename, // file to save headers
+                       u_int16_t   fpga_mask[C333_MAXHEIGHT>>5][C333_MAXWIDTH>>8], // [64][16]
+                       u_int32_t   fpga_zerobin[6],
+                       u_int32_t   fpga_qtables[512],
+                       u_int16_t   fpga_hti    [12],
+                       u_int16_t   fpga_hti30  [16],
+                       u_int32_t   fpga_htable [1024],
+                       u_int16_t   fpga_firstbit[4],
+                       int         nstx, //number of supertiles (128x64) horizontal
+                       int         nsty, //number of supertiles (128x64) vertical
+                       int         frn,  // frame rate nominator (1000000=1fps)
+                       int         nobr, // (-1 - "undfined")
+                       int         qual, // realtive quality =16
+                       int         kfgshiftm,
+                       char       *vendor, // "Xiph.Org libTheora I 20040317 3 2 0"
+                       int         nuser,
+                       char      **user,
+// selective qi and skipping blocks is not tested yet
+                       int         qual_left,
+                       int         qual_bottom,
+                       int         qual_right,
+                       int         qual_top,
+                       int         skip_left,
+                       int         skip_bottom,
+                       int         skip_right,
+                       int         skip_top,
+                       int         qis[2], // 0..63 if both are the same, single qi will be encoded
+                       int         sharpness, // 0..2 - is it obsolete in encodr now?
+// table that maps combinbatins of (frame type: 0 - intra, 1  inter whole, 2 - inter, partial (mapped)), AC(/DC) and chroma(/luma)
+// to internal (FPGA) indices (1-of-6 - not 1-of-16 as there is not enough room in FPGA Block RAM) 
+                       int         pre_ht[12],
+// this table maps intenal (1-of-6) Huffman table index to the standard 1-of-16. Not all the tables in the standard set of 80 can work -
+// currently code length is limited to 14 bits
+                       int         pre_ht30[6]){
+//     char       s[1024];
+//     char      *cp;
+//     char      *ep;
+     int        i,d; //j,r;
+     int        fmbw=nstx<<3; // width in macroblocks
+     int        fmbh=nsty<<2; // height in macroblocks
+     const int  frd=1000000;  // frame rate denominator (1000000)
+//     u_int32_t  kfgshiftm;  // number of bits in granule used for number of i-frames
+     char       packet1[44];
+     char       packet2[4096];
+     char       packet3[4096];
+     len_data_t packets[6];
+     
+     int        width = fmbw << 4;
+     int        height= fmbh << 4; 
+     len_data_t frame_headers[3];
+     int        nqis=(qis[1]==qis[0])?1:2;
+     FILE      *ofile;
+     const u_int32_t FPGA_ZEROBIN_TAB[6]={ // Index Sharpness S.Fact>50 Zbin       Round
+                                           0x80a6, //   0       0        0      0.65(166)  0.499(128)
+                                           0x76a6, //   1       0        1      0.65(166)  0.460(118)
+                                           0x7ac0, //   2       1        0      0.75(192)  0.476(122)
+                                           0x66c0, //   3       1        1      0.75(192)  0.400(102)
+                                           0x7ae6, //   4       2        0      0.90(230)  0.476(122)
+                                           0x55e6};//   5       2        1      0.90(230)  0.333( 85)
+     
+     memcpy (fpga_zerobin,FPGA_ZEROBIN_TAB,sizeof(FPGA_ZEROBIN_TAB));
+
+     packets[0].data=packet1; packets[0].len=42;
+     packets[1].data=packet2; packets[1].len=4096;
+     packets[2].data=packet3; packets[2].len=4096;
+     packets[0].len=theora_identification (packets[0].data,fmbw,fmbh,frn,frd, nobr, qual, kfgshiftm); //28
+     if (packets[1].len < 0) return packets[1].len;
+     packets[1].len=theora_comments (packets[1].data, packets[1].len, vendor, nuser, (const char **) user);
+     if (packets[1].len < 0) return packets[1].len;
+     packets[2].len=theora_setup (packets[2].data,packets[2].len, theora_LFLIMS, theora_ACSCALE, theora_DCSCALE, theora_BMS);
+     if (packets[2].len < 0) return packets[2].len;
+     fill_fpga_mask_windows (fpga_mask, width, height, qual_left, qual_bottom, qual_right, qual_top,
+                             skip_left, skip_bottom, skip_right, skip_top);
+     theora_frameheaders (width, height, frame_headers, nqis, qis, fpga_mask); //mask_array);
+     for (i=0;i<3;i++)  fpga_firstbit[i] = frame_headers[i].len & 0x1f;
+ // three different frame headers
+     packets[3].len= frame_headers[0].len;
+     packets[3].data=frame_headers[0].data;
+     packets[4].len= frame_headers[1].len;
+     packets[4].data=frame_headers[1].data;
+     packets[5].len= frame_headers[2].len;
+     packets[5].data=frame_headers[2].data;
+// build quantization tables to be loaded to FPGA
+     fill_FPGA_qtables (fpga_qtables,
+                        sharpness,
+                        qis[0],   // index in DC_Scale/AC_Scale tables, intra frame, luma
+                        qis[0],   // index in DC_Scale/AC_Scale tables, intra frame, chroma
+                        qis[0],   // index in DC_Scale/AC_Scale tables, inter frame, luma
+                        qis[0],   // index in DC_Scale/AC_Scale tables, inter frame, chroma
+
+                        qis[1],   // index in DC_Scale/AC_Scale tables, intra frame, luma
+                        qis[1],   // index in DC_Scale/AC_Scale tables, intra frame, chroma
+                        qis[1],   // index in DC_Scale/AC_Scale tables, inter frame, luma
+                        qis[1]);  // index in DC_Scale/AC_Scale tables, inter frame, chroma
+// build Huffman tables to be loaded to FPGA
+    if ((i=fill_FPGA_htables (fpga_hti, fpga_hti30, fpga_htable, pre_ht, pre_ht30))<0) return -5;
+
+// now save all 6 packets (3 stream headers and 3 different frame headers) in a file.
+// Data will be 32-bit aligned, first word will be 6 (number of packets, then length of each one (in bits!) then packets 32-bit aligned
+  
+    if ((ofile = fopen(headers_filename, "w"))==NULL)
+       {fprintf(stderr,"error opening file %s for writing - error = %d (%s)\n",headers_filename,errno,strerror(errno)); return -1;}
+    d=6;   
+    if (fwrite(&d, 4, 1, ofile)<1) return -2;
+    for (i=0;i<6;i++) {
+       d=packets[i].len;
+       if (i<3) d<<=3; // make them all in bits (first 3 were in bytes)
+       if (fwrite(&d, 4, 1, ofile)<1) return -2;
+    }
+    if (fwrite(&kfgshiftm, 4, 1, ofile)<1) return -2; // save it for the second part - sending clip out
+D(int ii=0;)     
+    for (i=0;i<6;i++) {
+       d=packets[i].len;
+       if (i<3) d<<=3; // make them all in bits (first 3 were in bytes)
+       d= (d+31) >> 5;
+         
+         D(for (ii=0;ii<20;ii++) fprintf(stderr," %x",0xff & packets[i].data[ii]));
+         D(fprintf(stderr,"\n"));
+       if (fwrite(packets[i].data, 4,d, ofile)<(unsigned)d) return -3;
+    }
+    fclose (ofile);
+    for (i=0; i<3; i++) free(frame_headers[i].data);
+    return 0;
+ }
+// now encapsulate compressed data and output stream (to stdout?)
+// The two arrays will be just mmap-ed in the camera
+int oggtheora_send    (const char *headers_filename, // filename of a file with 6 headers and their lengths (in bits)
+                       u_int8_t    ccam_dma      [CCAM_BYTES_PER_DMABUF],
+                       u_int32_t   ccam_dma_index[CCAM_DMA_INDEX_SIZE],
+                       u_int32_t   stream_serial) {
+    int        kfgshiftm=9;
+    len_data_t packets[6];
+    FILE      *headers_file;
+    u_int32_t  num_headers;
+    u_int32_t  header_lengths[6];
+    int        i,r;
+
+    if ((headers_file = fopen(headers_filename, "r"))==NULL) {
+        fprintf(stderr,"error opening file %s for reading - error = %d (%s)\n",
+                                         headers_filename,errno,strerror(errno)); 
+        return -1;
+    }
+    if (fread (&num_headers,   4, 1, headers_file)<1) 
+        return -4;
+    if (num_headers!=6) 
+        return -5;
+    if (fread (header_lengths, 4, 6, headers_file)<6) 
+        return -5;
+    if (fread (&kfgshiftm,     4, 1, headers_file)<1) 
+        return -5;
+
+    for (i=0;i<3;i++) 
+        packets[i].len=header_lengths[i]>>3; // now - in bytes
+    for (i=3;i<6;i++) 
+        packets[i].len=header_lengths[i]; // these are needed to be in bits
+    for (i=0;i<6;i++) {
+        header_lengths[i]=(header_lengths[i]+31)>>5;
+        packets[i].data=malloc(header_lengths[i]<<2);
+        if (((r=fread (packets[i].data, 4, header_lengths[i], headers_file))) < (int)header_lengths[i]) {
+            fprintf(stderr, "i=%d, fread returned %d, wanted - %d\n",i, r,header_lengths[i]);
+            return -6;
+        }     
+    }
+    fclose(headers_file);
+
+    D(fprintf(stderr, "oggtheora_send:stream_serial=%x\n",stream_serial));
+    i= makeOggTheora( ccam_dma_index, // will be mmaped array in the camera
+                      ccam_dma,       // will be mmaped array in the camera (char array)
+                      stdout,         // output stream
+                      8192,           // page_size,      // maximal page size to use
+                      packets,        // headers:
+                                      // 0 - identification
+                                      // 1 - comment
+                                      // 2 - setup
+                                      // 3 - frame - intra (.len - in bits, not bytes!)
+                                      // 4 - frame - inter/full
+                                      // 5 - frame - inter/mapped
+                      stream_serial,
+                      kfgshiftm);        // number of bits in granule used for number of i-frames
+    for (i=0; i<6; i++) 
+        free(packets[i].data);
+    return i;
+}
+
+
+char * fnegets(FILE* fin, char * s) {
+      int i;
+      char * cp;
+      fgets(s, 1024, fin);
+      while ((s[(i=strspn(s," \t\n"))]=='#') || (s[i]==0)) fgets(s, 1024, fin);;
+      cp = s +strspn(s," \t");
+      for (i=strlen(cp)-1;strchr(" \t\n",cp[i]) && (i>0);i--) cp[i]=0;
+return cp;
+}
+
+
+int  setup_tbl_FPGA( int nframes_total,
+             int nframes_inter_full, // number of INTER frames (full) after each INTRA
+                     int nframes_inter_masked, // number of INTER frames (masked) after each INTER full (not tested yet)
+                     int time_slow)   // reduce reported fps by this
+  {
+
+     char       headers_filename[]="/tmp/headers";
+     char       parameters_filename[]="/etc/oggtheora_params";
+     char       controlfn[]="/dev/ccam_img";
+     char       fpga_tables_fn[]="/dev/fpga_tables";
+     char       s[1024];
+     char      *cp;
+     char      *ep;
+     int        i,j; //,r;
+     int        nstx; // width  in superblocks
+     int        nsty; // height in superblocks
+     int        frn; // frame rate nominator ( in 1/1000000)
+     int        nobr; // nominal bit rate (-1 - undefined?)
+     int        qual; // relative quality (was 0x10)
+     int        kfgshiftm=9; // will calculate
+     int        nuser = 1;
+     char      *vendor = NULL;
+     char     **user=NULL;
+     
+     int        qual_left; // all in pixels, high quality will be inside and including the spacified coordinates
+     int        qual_bottom;
+     int        qual_right;
+     int        qual_top;
+     int        skip_left;
+     int        skip_bottom;
+     int        skip_right;
+     int        skip_top;
+     int        nqis;
+     int        qis[2];
+     int  sharpness;       // 0-2 - obsolete now in Theora
+
+     int  pre_ht[12];
+     int  pre_ht30[6];
+    
+
+     u_int16_t   fpga_mask[C333_MAXHEIGHT>>5][C333_MAXWIDTH>>8]; // [64][16]
+     u_int32_t   fpga_zerobin[6];
+     u_int32_t   fpga_qtables[512];
+     u_int16_t   fpga_hti    [12];
+     u_int16_t   fpga_hti30  [16];
+     u_int32_t   fpga_htable [1024];
+     u_int16_t   fpga_firstbit[4];
+
+     int fpga_tables_fd;
+     u_int32_t d[2];
+
+     FILE *ifile;
+     int devfd;
+
+     i= (nframes_inter_masked+1)*nframes_inter_full; // "period-1" of INTRA frames
+     for (kfgshiftm=0;i!=0;i>>=1) kfgshiftm++;
+      if  (kfgshiftm<6) kfgshiftm=6;
+
+
+// read parameters from file, then replace some with current
+     if ((ifile = fopen(parameters_filename, "r"))==NULL)
+        {fprintf(stderr,"error opening file %s for reading - error = %d (%s)\n",parameters_filename,errno,strerror(errno)); return -1;}
+
+     cp=fnegets(ifile,s); nstx=          strtol (cp,&ep,10);
+     cp=fnegets(ifile,s); nsty=          strtol (cp,&ep,10);
+     cp=fnegets(ifile,s); frn=           strtol (cp,&ep,10);
+     cp=fnegets(ifile,s); nobr=          strtol (cp,&ep,10);
+     cp=fnegets(ifile,s); qual=          strtol (cp,&ep,10);
+     vendor= strdup(fnegets(ifile,s));
+     cp=fnegets(ifile,s); nuser=     strtol (cp,&ep,10);
+     if (nuser) {
+       user= (char**) malloc(nuser * sizeof (cp));
+       for (i=0; i<nuser;i++) user[i] = strdup(fnegets(ifile,s));
+     }
+     cp=fnegets(ifile,s); if (cp[0]!='=') { fprintf(stderr, "expecting separator (=) line\n"); return -3;}
+     cp=fnegets(ifile,s); qual_left=     strtol (cp,&ep,10);
+     cp=fnegets(ifile,s); qual_bottom=   strtol (cp,&ep,10);
+     cp=fnegets(ifile,s); qual_right=    strtol (cp,&ep,10);
+     cp=fnegets(ifile,s); qual_top=      strtol (cp,&ep,10);
+     cp=fnegets(ifile,s); skip_left=     strtol (cp,&ep,10);
+     cp=fnegets(ifile,s); skip_bottom=   strtol (cp,&ep,10);
+     cp=fnegets(ifile,s); skip_right=    strtol (cp,&ep,10);
+     cp=fnegets(ifile,s); skip_top=      strtol (cp,&ep,10);
+     cp=fnegets(ifile,s); nqis=          strtol (cp,&ep,10);
+     for (i=0; i<nqis; i++) {cp=fnegets(ifile,s); qis[i]=     strtol (cp,&ep,10);}
+     if (nqis<2) qis[1]=qis[0];
+     cp=fnegets(ifile,s); if (cp[0]!='=') { fprintf(stderr, "expecting separator (=) line\n"); return -3;}
+     cp=fnegets(ifile,s); sharpness=      strtol (cp,&ep,10);
+     cp=fnegets(ifile,s); if (cp[0]!='=') { fprintf(stderr, "expecting separator (=) line\n"); return -3;}
+     ep=fnegets(ifile,s); for (i=0;i<12;i++) { cp=ep; pre_ht[i]=    strtol (cp,&ep,10);}
+     ep=fnegets(ifile,s); for (i=0;i<6; i++) { cp=ep; pre_ht30[i]=  strtol (cp,&ep,10);}
+     cp=fnegets(ifile,s); if (cp[0]!='=') { fprintf(stderr, "expecting separator (=) line\n"); return -3;}
+     fclose (ifile);
+
+// read frame size, frame rate from sensor
+    if ((devfd = open(controlfn, O_RDONLY)) <0)
+      {fprintf(stderr,"error opening file %s for reading - error = %d (%s)\n",controlfn,errno,strerror(errno)); return -1;}
+     nstx=ioctl(devfd, _CCCMD( CCAM_RPARS , P_ACTUAL_WIDTH), 0)>>7;
+     nsty=ioctl(devfd, _CCCMD( CCAM_RPARS , P_ACTUAL_HEIGHT), 0)>>6;
+     frn=(ioctl(devfd, _CCCMD( CCAM_RPARS , P_FP100S), 0)*10000)/time_slow;
+     qis[1]=qis[0]=(ioctl(devfd, _CCCMD( CCAM_RPARS , P_QUALITY), 0)*63)/100;
+     fprintf(stderr,"fps=%d/1000000\r\n",frn);
+    close (devfd);
+ 
+// now prepare headers and FPGA tables
+     i=oggtheora_prepare (headers_filename, // file to save headers
+                       fpga_mask, // [64][16]
+                       fpga_zerobin,
+                       fpga_qtables,
+                       fpga_hti,
+                       fpga_hti30,
+                       fpga_htable,
+                       fpga_firstbit,
+                       nstx, //number of supertiles (128x64) horizontal
+                       nsty, //number of supertiles (128x64) vertical
+                       frn,  // frame rate nominator (1000000=1fps)
+                       nobr, // (-1 - "undfined")
+                       qual, // realtive quality =16
+                       kfgshiftm,
+                       vendor, // "Xiph.Org libTheora I 20040317 3 2 0"
+                       nuser,
+                       user,
+// selective qi and skipping blocks is not tested yet
+                       qual_left,
+                       qual_bottom,
+                       qual_right,
+                       qual_top,
+                       skip_left,
+                       skip_bottom,
+                       skip_right,
+                       skip_top,
+                       qis, // 0..63 if both are the same, single qi will be encoded
+                       sharpness, // 0..2 - is it obsolete in encodr now?
+// table that maps combinbatins of (frame type: 0 - intra, 1  inter whole, 2 - inter, partial (mapped)), AC(/DC) and chroma(/luma)
+// to internal (FPGA) indices (1-of-6 - not 1-of-16 as there is not enough room in FPGA Block RAM) 
+                       pre_ht,
+// this table maps intenal (1-of-6) Huffman table index to the standard 1-of-16. Not all the tables in the standard set of 80 can work -
+// currently code length is limited to 14 bits
+                       pre_ht30);
+// free used stings
+     free(vendor);
+     if (nuser) {
+       for (i=0; i<nuser;i++) free (user[i]);
+       free (user);
+     }
+// write tables to FPGA
+  
+     fpga_tables_fd = open(fpga_tables_fn, O_RDWR);
+     lseek(fpga_tables_fd, 0x400<< 2,0);// 400 - start of zerobin table in fpga
+     write(fpga_tables_fd, fpga_zerobin,6<<2);
+
+     lseek(fpga_tables_fd, 0x0  << 2,0);// qtables
+     for (i=0;i<512;i++) {
+        d[0]=  fpga_qtables[i] & 0xffff;
+        d[1]= (fpga_qtables[i] >> 16) & 0xffff;
+        write(fpga_tables_fd, d,8);
+     }
+     
+     lseek(fpga_tables_fd, 0x1400  << 2,0);// hti
+     for (i=0;i<12;i++)  {
+        d[0]=  fpga_hti[i];
+        write(fpga_tables_fd, d,4);
+     }
+    
+     lseek(fpga_tables_fd, 0x1500  << 2,0);// hti30
+     for (i=0;i<16;i++)  {
+        d[0]=  fpga_hti30[i];
+        write(fpga_tables_fd, d,4);
+     }
+
+     lseek(fpga_tables_fd, 0x1000<< 2,0);// htable
+     write(fpga_tables_fd, fpga_htable,1024<<2);
+
+
+     lseek(fpga_tables_fd, 0x1600  << 2,0);// map
+     for (i=0;i<3; i++)  {
+        d[0]=  fpga_firstbit[i];
+        write(fpga_tables_fd, d,4);
+     }
+
+     lseek(fpga_tables_fd, 0xc00 << 2,0);// firstbit
+     for (i=0;i<(C333_MAXHEIGHT>>5);i++) for (j=0;j<(C333_MAXWIDTH>>8);j++) {
+        d[0]=  fpga_mask[i][j];
+        write(fpga_tables_fd, d,4);
+     }
+     close (fpga_tables_fd);
+     
+return 0;
+}
+ 
+

Added: experimental/j/Elphel333/common/oggtheora.h
===================================================================
--- experimental/j/Elphel333/common/oggtheora.h	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/common/oggtheora.h	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,101 @@
+// Implementation of Theora RTP streaming
+// Copyright 2005 Elphel, Inc
+// Andrey Latin andrey.latin at gmail.com
+
+
+#ifndef __OGGTHEORA_STRM_H_DEF_
+#define __OGGTHEORA_STRM_H_DEF_
+
+typedef enum {
+    INTRA = 0,
+    INTER_FULL = 1,
+    INTER_PARTIAL = 2
+} FrameType;
+
+
+typedef struct {
+  int     len;
+  char *  data;
+} len_data_t;
+
+
+typedef struct {
+  u_int8_t            OggS[4];
+  u_int8_t            version;
+  u_int8_t            flags;
+//  u_int64_t           granule;
+//  u_int32_t           serial;
+//  u_int32_t           page;
+//  u_int32_t           crc;
+  u_int8_t           granule[8];
+  u_int8_t           serial[4];
+  u_int8_t           page[4];
+  u_int8_t           crc[4];
+  u_int8_t           num_segm;
+  u_int8_t           lacing_values [255];
+
+} ogg_header_t;
+
+
+#define C333_MAXWIDTH (4096)
+#define C333_MAXHEIGHT (2048)
+
+
+int oggtheora_prepare (const char *headers_filename, // file to save headers
+                       u_int16_t   fpga_mask[C333_MAXHEIGHT>>5][C333_MAXWIDTH>>8], // [64][16]
+                       u_int32_t   fpga_zerobin[6],
+                       u_int32_t   fpga_qtables[512],
+                       u_int16_t   fpga_hti    [12],
+                       u_int16_t   fpga_hti30  [16],
+                       u_int32_t   fpga_htable [1024],
+                       u_int16_t   fpga_firstbit[4],
+                       int         nstx, //number of supertiles (128x64) horizontal
+                       int         nsty, //number of supertiles (128x64) vertical
+                       int         frn,  // frame rate nominator (1000000=1fps)
+                       int         nobr, // (-1 - "undfined")
+                       int         qual, // realtive quality =16
+                       int         kfgshiftm,
+                       char       *vendor, // "Xiph.Org libTheora I 20040317 3 2 0"
+                       int         nuser,
+                       char      **user,
+// selective qi and skipping blocks is not tested yet
+                       int         qual_left,
+                       int         qual_bottom,
+                       int         qual_right,
+                       int         qual_top,
+                       int         skip_left,
+                       int         skip_bottom,
+                       int         skip_right,
+                       int         skip_top,
+                       int         qis[2], // 0..63 if both are the same, single qi will be encoded
+                       int         sharpness, // 0..2 - is it obsolete in encodr now?
+// table that maps combinbatins of (frame type: 0 - intra, 1  inter whole, 2 - inter, partial (mapped)), AC(/DC) and chroma(/luma)
+// to internal (FPGA) indices (1-of-6 - not 1-of-16 as there is not enough room in FPGA Block RAM) 
+                       int         pre_ht[12],
+// this table maps intenal (1-of-6) Huffman table index to the standard 1-of-16. Not all the tables in the standard set of 80 can work -
+// currently code length is limited to 14 bits
+                       int         pre_ht30[6]);
+
+
+// now encapsulate compressed data and output stream (to stdout?)
+// The two arrays will be just mmap-ed in the camera
+int oggtheora_send    (const char *headers_filename, // filename of a file with 6 headers and their lengths (in bits)
+                       u_int8_t    ccam_dma      [CCAM_BYTES_PER_DMABUF],
+                       u_int32_t   ccam_dma_index[CCAM_DMA_INDEX_SIZE],
+                       u_int32_t   stream_serial);
+
+
+int make_OggTheoraHdrs(const char *headers_filename);
+int fwrite_all(FILE *  stream, char * data, int len); 
+char * fnegets(FILE* fin, char * s);
+int  setup_tbl_FPGA( int nframes_total,
+		     int nframes_inter_full, // number of INTER frames (full) after each INTRA
+                     int nframes_inter_masked, // number of INTER frames (masked) after each INTER full (not tested yet)
+                     int time_slow);   // reduce reported fps by this
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif 
+                      

Added: experimental/j/Elphel333/common/oggtheora_tables.h
===================================================================
--- experimental/j/Elphel333/common/oggtheora_tables.h	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/common/oggtheora_tables.h	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,952 @@
+
+static const u_int32_t crc_lookup[256]={
+  0x00000000,0x04c11db7,0x09823b6e,0x0d4326d9,
+  0x130476dc,0x17c56b6b,0x1a864db2,0x1e475005,
+  0x2608edb8,0x22c9f00f,0x2f8ad6d6,0x2b4bcb61,
+  0x350c9b64,0x31cd86d3,0x3c8ea00a,0x384fbdbd,
+  0x4c11db70,0x48d0c6c7,0x4593e01e,0x4152fda9,
+  0x5f15adac,0x5bd4b01b,0x569796c2,0x52568b75,
+  0x6a1936c8,0x6ed82b7f,0x639b0da6,0x675a1011,
+  0x791d4014,0x7ddc5da3,0x709f7b7a,0x745e66cd,
+  0x9823b6e0,0x9ce2ab57,0x91a18d8e,0x95609039,
+  0x8b27c03c,0x8fe6dd8b,0x82a5fb52,0x8664e6e5,
+  0xbe2b5b58,0xbaea46ef,0xb7a96036,0xb3687d81,
+  0xad2f2d84,0xa9ee3033,0xa4ad16ea,0xa06c0b5d,
+  0xd4326d90,0xd0f37027,0xddb056fe,0xd9714b49,
+  0xc7361b4c,0xc3f706fb,0xceb42022,0xca753d95,
+  0xf23a8028,0xf6fb9d9f,0xfbb8bb46,0xff79a6f1,
+  0xe13ef6f4,0xe5ffeb43,0xe8bccd9a,0xec7dd02d,
+  0x34867077,0x30476dc0,0x3d044b19,0x39c556ae,
+  0x278206ab,0x23431b1c,0x2e003dc5,0x2ac12072,
+  0x128e9dcf,0x164f8078,0x1b0ca6a1,0x1fcdbb16,
+  0x018aeb13,0x054bf6a4,0x0808d07d,0x0cc9cdca,
+  0x7897ab07,0x7c56b6b0,0x71159069,0x75d48dde,
+  0x6b93dddb,0x6f52c06c,0x6211e6b5,0x66d0fb02,
+  0x5e9f46bf,0x5a5e5b08,0x571d7dd1,0x53dc6066,
+  0x4d9b3063,0x495a2dd4,0x44190b0d,0x40d816ba,
+  0xaca5c697,0xa864db20,0xa527fdf9,0xa1e6e04e,
+  0xbfa1b04b,0xbb60adfc,0xb6238b25,0xb2e29692,
+  0x8aad2b2f,0x8e6c3698,0x832f1041,0x87ee0df6,
+  0x99a95df3,0x9d684044,0x902b669d,0x94ea7b2a,
+  0xe0b41de7,0xe4750050,0xe9362689,0xedf73b3e,
+  0xf3b06b3b,0xf771768c,0xfa325055,0xfef34de2,
+  0xc6bcf05f,0xc27dede8,0xcf3ecb31,0xcbffd686,
+  0xd5b88683,0xd1799b34,0xdc3abded,0xd8fba05a,
+  0x690ce0ee,0x6dcdfd59,0x608edb80,0x644fc637,
+  0x7a089632,0x7ec98b85,0x738aad5c,0x774bb0eb,
+  0x4f040d56,0x4bc510e1,0x46863638,0x42472b8f,
+  0x5c007b8a,0x58c1663d,0x558240e4,0x51435d53,
+  0x251d3b9e,0x21dc2629,0x2c9f00f0,0x285e1d47,
+  0x36194d42,0x32d850f5,0x3f9b762c,0x3b5a6b9b,
+  0x0315d626,0x07d4cb91,0x0a97ed48,0x0e56f0ff,
+  0x1011a0fa,0x14d0bd4d,0x19939b94,0x1d528623,
+  0xf12f560e,0xf5ee4bb9,0xf8ad6d60,0xfc6c70d7,
+  0xe22b20d2,0xe6ea3d65,0xeba91bbc,0xef68060b,
+  0xd727bbb6,0xd3e6a601,0xdea580d8,0xda649d6f,
+  0xc423cd6a,0xc0e2d0dd,0xcda1f604,0xc960ebb3,
+  0xbd3e8d7e,0xb9ff90c9,0xb4bcb610,0xb07daba7,
+  0xae3afba2,0xaafbe615,0xa7b8c0cc,0xa379dd7b,
+  0x9b3660c6,0x9ff77d71,0x92b45ba8,0x9675461f,
+  0x8832161a,0x8cf30bad,0x81b02d74,0x857130c3,
+  0x5d8a9099,0x594b8d2e,0x5408abf7,0x50c9b640,
+  0x4e8ee645,0x4a4ffbf2,0x470cdd2b,0x43cdc09c,
+  0x7b827d21,0x7f436096,0x7200464f,0x76c15bf8,
+  0x68860bfd,0x6c47164a,0x61043093,0x65c52d24,
+  0x119b4be9,0x155a565e,0x18197087,0x1cd86d30,
+  0x029f3d35,0x065e2082,0x0b1d065b,0x0fdc1bec,
+  0x3793a651,0x3352bbe6,0x3e119d3f,0x3ad08088,
+  0x2497d08d,0x2056cd3a,0x2d15ebe3,0x29d4f654,
+  0xc5a92679,0xc1683bce,0xcc2b1d17,0xc8ea00a0,
+  0xd6ad50a5,0xd26c4d12,0xdf2f6bcb,0xdbee767c,
+  0xe3a1cbc1,0xe760d676,0xea23f0af,0xeee2ed18,
+  0xf0a5bd1d,0xf464a0aa,0xf9278673,0xfde69bc4,
+  0x89b8fd09,0x8d79e0be,0x803ac667,0x84fbdbd0,
+  0x9abc8bd5,0x9e7d9662,0x933eb0bb,0x97ffad0c,
+  0xafb010b1,0xab710d06,0xa6322bdf,0xa2f33668,
+  0xbcb4666d,0xb8757bda,0xb5365d03,0xb1f740b4};
+
+static const char theora_string[6]={0x74,0x68,0x65,0x6f,0x72,0x61};
+static const char oggs_string[4]=  {0x4f,0x67,0x67,0x53};
+
+
+static const int theora_BMS[3][64]= {
+  {
+     16, 11, 10, 16, 24,  40, 51, 61,
+     12, 12, 14, 19, 26,  58, 60, 55,
+     14, 13, 16, 24, 40,  57, 69, 56,
+     14, 17, 22, 29, 51,  87, 80, 62,
+     18, 22, 37, 58, 68, 109,103, 77,
+     24, 35, 55, 64, 81, 104,113, 92,
+     49, 64, 78, 87,103, 121,120,101,
+     72, 92, 95, 98,112, 100,103, 99
+  },
+  {
+     17, 18, 24, 47, 99, 99, 99, 99,
+     18, 21, 26, 66, 99, 99, 99, 99,
+     24, 26, 56, 99, 99, 99, 99, 99,
+     47, 66, 99, 99, 99, 99, 99, 99,
+     99, 99, 99, 99, 99, 99, 99, 99,
+     99, 99, 99, 99, 99, 99, 99, 99,
+     99, 99, 99, 99, 99, 99, 99, 99,
+     99, 99, 99, 99, 99, 99, 99, 99
+  },
+  {
+     16, 16, 16, 20, 24, 28, 32, 40,
+     16, 16, 20, 24, 28, 32, 40, 48,
+     16, 20, 24, 28, 32, 40, 48, 64,
+     20, 24, 28, 32, 40, 48, 64, 64,
+     24, 28, 32, 40, 48, 64, 64, 64,
+     28, 32, 40, 48, 64, 64, 64, 96,
+     32, 40, 48, 64, 64, 64, 96,128,
+     40, 48, 64, 64, 64, 96,128,128
+  }
+ } ;
+
+static const int theora_DCSCALE[]= {
+    220,200,190,180,170,170,160,160,
+    150,150,140,140,130,130,120,120,
+    110,110,100,100, 90, 90, 90, 80,
+     80, 80, 70, 70, 70, 60, 60, 60,
+     60, 50, 50, 50, 50, 40, 40, 40,
+     40, 40, 30, 30, 30, 30, 30, 30,
+     30, 20, 20, 20, 20, 20, 20, 20,
+     20, 10, 10, 10, 10, 10, 10, 10
+  };
+static const int theora_ACSCALE[]= {
+    500,450,400,370,340,310,285,265,
+    245,225,210,195,185,180,170,160,
+    150,145,135,130,125,115,110,107,
+    100, 96, 93, 89, 85, 82, 75, 74,
+     70, 68, 64, 60, 57, 56, 52, 50,
+     49, 45, 44, 43, 40, 38, 37, 35,
+     33, 32, 30, 29, 28, 25, 24, 22,
+     21, 19, 18, 17, 15, 13, 12, 10
+  };
+#if 0  
+static const int theora_LFLIMS[]= { // not used now
+    30,25,20,20,15,15,14,14,
+    13,13,12,12,11,11,10,10,
+     9, 9, 8, 8, 7, 7, 7, 7,
+     6, 6, 6, 6, 5, 5, 5, 5,
+     4, 4, 4, 4, 3, 3, 3, 3,
+     2, 2, 2, 2, 2, 2, 2, 2,
+     0, 0, 0, 0, 0, 0, 0, 0,
+     0, 0, 0, 0, 0, 0, 0, 0
+  };
+#else
+static const int theora_LFLIMS[]= { // not used now
+     0, 0, 0, 0, 0, 0, 0, 0,
+     0, 0, 0, 0, 0, 0, 0, 0,
+     0, 0, 0, 0, 0, 0, 0, 0,
+     0, 0, 0, 0, 0, 0, 0, 0,
+     0, 0, 0, 0, 0, 0, 0, 0,
+     0, 0, 0, 0, 0, 0, 0, 0,
+     0, 0, 0, 0, 0, 0, 0, 0,
+     0, 0, 0, 0, 0, 0, 0, 0
+  };
+#endif
+/*The default Huffman codes used for VP3.1.*/
+// value, length - ordered in token number order
+const theora_huff_code OC_VP31_HUFF_CODES[OC_NHUFFMAN_TABLES][OC_NDCT_TOKENS]={
+  {
+    {0x002D, 6},{0x0026, 7},{0x0166, 9},{0x004E, 8},
+    {0x02CE,10},{0x059E,11},{0x027D,11},{0x0008, 5},
+    {0x04F9,12},{0x000F, 4},{0x000E, 4},{0x001B, 5},
+    {0x0006, 4},{0x0008, 4},{0x0005, 4},{0x001A, 5},
+    {0x0015, 5},{0x0007, 4},{0x000C, 4},{0x0001, 3},
+    {0x0000, 3},{0x0009, 4},{0x0017, 5},{0x0029, 6},
+    {0x0028, 6},{0x00B2, 8},{0x04F8,12},{0x059F,11},
+    {0x009E, 9},{0x013F,10},{0x0012, 6},{0x0058, 7}
+  },
+  {
+    {0x0010, 5},{0x0047, 7},{0x01FF, 9},{0x008C, 8},
+    {0x03FC,10},{0x046A,11},{0x0469,11},{0x0022, 6},
+    {0x11A1,13},{0x000E, 4},{0x000D, 4},{0x0004, 4},
+    {0x0005, 4},{0x0009, 4},{0x0006, 4},{0x001E, 5},
+    {0x0016, 5},{0x0007, 4},{0x000C, 4},{0x0001, 3},
+    {0x0000, 3},{0x000A, 4},{0x0017, 5},{0x007D, 7},
+    {0x007E, 7},{0x011B, 9},{0x08D1,12},{0x03FD,10},
+    {0x046B,11},{0x11A0,13},{0x007C, 7},{0x00FE, 8}
+  },
+  {
+    {0x0016, 5},{0x0020, 6},{0x0086, 8},{0x0087, 8},
+    {0x0367,10},{0x06CC,11},{0x06CB,11},{0x006E, 7},
+    {0x366D,14},{0x000F, 4},{0x000E, 4},{0x0004, 4},
+    {0x0005, 4},{0x000A, 4},{0x0006, 4},{0x001A, 5},
+    {0x0011, 5},{0x0007, 4},{0x000C, 4},{0x0001, 3},
+    {0x0000, 3},{0x0009, 4},{0x0017, 5},{0x006F, 7},
+    {0x006D, 7},{0x0364,10},{0x0D9A,12},{0x06CA,11},
+    {0x1B37,13},{0x366C,14},{0x0042, 7},{0x00D8, 8}
+  },
+  {
+    {0x0000, 4},{0x002D, 6},{0x00F7, 8},{0x0058, 7},
+    {0x0167, 9},{0x02CB,10},{0x02CA,10},{0x000E, 6},
+    {0x1661,13},{0x0003, 3},{0x0002, 3},{0x0008, 4},
+    {0x0009, 4},{0x000D, 4},{0x0002, 4},{0x001F, 5},
+    {0x0017, 5},{0x0001, 4},{0x000C, 4},{0x000E, 4},
+    {0x000A, 4},{0x0006, 5},{0x0078, 7},{0x000F, 6},
+    {0x007A, 7},{0x0164, 9},{0x0599,11},{0x02CD,10},
+    {0x0B31,12},{0x1660,13},{0x0079, 7},{0x00F6, 8}
+  },
+  {
+    {0x0003, 4},{0x003C, 6},{0x000F, 7},{0x007A, 7},
+    {0x001D, 8},{0x0020, 9},{0x0072,10},{0x0006, 6},
+    {0x0399,13},{0x0004, 3},{0x0005, 3},{0x0005, 4},
+    {0x0006, 4},{0x000E, 4},{0x0004, 4},{0x0000, 4},
+    {0x0019, 5},{0x0002, 4},{0x000D, 4},{0x0007, 4},
+    {0x001F, 5},{0x0030, 6},{0x0011, 8},{0x0031, 6},
+    {0x0005, 6},{0x0021, 9},{0x00E7,11},{0x0038, 9},
+    {0x01CD,12},{0x0398,13},{0x007B, 7},{0x0009, 7}
+  },
+  {
+    {0x0009, 4},{0x0002, 5},{0x0074, 7},{0x0007, 6},
+    {0x00EC, 8},{0x00D1, 9},{0x01A6,10},{0x0006, 6},
+    {0x0D21,13},{0x0005, 3},{0x0006, 3},{0x0008, 4},
+    {0x0007, 4},{0x000F, 4},{0x0004, 4},{0x0000, 4},
+    {0x001C, 5},{0x0002, 4},{0x0005, 4},{0x0003, 4},
+    {0x000C, 5},{0x0035, 7},{0x01A7,10},{0x001B, 6},
+    {0x0077, 7},{0x01A5,10},{0x0349,11},{0x00D0, 9},
+    {0x0691,12},{0x0D20,13},{0x0075, 7},{0x00ED, 8}
+  },
+  {
+    {0x000A, 4},{0x000C, 5},{0x0012, 6},{0x001B, 6},
+    {0x00B7, 8},{0x016C, 9},{0x0099, 9},{0x005A, 7},
+    {0x16D8,13},{0x0007, 3},{0x0006, 3},{0x0009, 4},
+    {0x0008, 4},{0x0000, 3},{0x0005, 4},{0x0017, 5},
+    {0x000E, 5},{0x0002, 4},{0x0003, 4},{0x000F, 5},
+    {0x001A, 6},{0x004D, 8},{0x2DB3,14},{0x002C, 6},
+    {0x0011, 6},{0x02DA,10},{0x05B7,11},{0x0098, 9},
+    {0x0B6D,12},{0x2DB2,14},{0x0010, 6},{0x0027, 7}
+  },
+  {
+    {0x000D, 4},{0x000F, 5},{0x001D, 6},{0x0008, 5},
+    {0x0051, 7},{0x0056, 8},{0x00AF, 9},{0x002A, 7},
+    {0x148A,13},{0x0007, 3},{0x0000, 2},{0x0008, 4},
+    {0x0009, 4},{0x000C, 4},{0x0006, 4},{0x0017, 5},
+    {0x000B, 5},{0x0016, 5},{0x0015, 5},{0x0009, 5},
+    {0x0050, 7},{0x00AE, 9},{0x2917,14},{0x001C, 6},
+    {0x0014, 6},{0x0290,10},{0x0523,11},{0x0149, 9},
+    {0x0A44,12},{0x2916,14},{0x0053, 7},{0x00A5, 8}
+  },
+  {
+    {0x0001, 4},{0x001D, 6},{0x00F5, 8},{0x00F4, 8},
+    {0x024D,10},{0x0499,11},{0x0498,11},{0x0001, 5},
+    {0x0021, 6},{0x0006, 3},{0x0005, 3},{0x0006, 4},
+    {0x0005, 4},{0x0002, 4},{0x0007, 5},{0x0025, 6},
+    {0x007B, 7},{0x001C, 6},{0x0020, 6},{0x000D, 6},
+    {0x0048, 7},{0x0092, 8},{0x0127, 9},{0x000E, 4},
+    {0x0004, 4},{0x0011, 5},{0x000C, 6},{0x003C, 6},
+    {0x000F, 5},{0x0000, 5},{0x001F, 5},{0x0013, 5}
+  },
+  {
+    {0x0005, 4},{0x003C, 6},{0x0040, 7},{0x000D, 7},
+    {0x0031, 9},{0x0061,10},{0x0060,10},{0x0002, 5},
+    {0x00F5, 8},{0x0006, 3},{0x0005, 3},{0x0007, 4},
+    {0x0006, 4},{0x0002, 4},{0x0009, 5},{0x0025, 6},
+    {0x0007, 6},{0x0021, 6},{0x0024, 6},{0x0010, 6},
+    {0x0041, 7},{0x00F4, 8},{0x0019, 8},{0x000E, 4},
+    {0x0003, 4},{0x0011, 5},{0x0011, 6},{0x003F, 6},
+    {0x003E, 6},{0x007B, 7},{0x0000, 4},{0x0013, 5}
+  },
+  {
+    {0x000A, 4},{0x0007, 5},{0x0001, 6},{0x0009, 6},
+    {0x0131, 9},{0x0261,10},{0x0260,10},{0x0015, 6},
+    {0x0001, 7},{0x0007, 3},{0x0006, 3},{0x0008, 4},
+    {0x0007, 4},{0x0006, 4},{0x0012, 5},{0x002F, 6},
+    {0x0014, 6},{0x0027, 6},{0x002D, 6},{0x0016, 6},
+    {0x004D, 7},{0x0099, 8},{0x0000, 7},{0x0004, 4},
+    {0x0001, 4},{0x0005, 5},{0x0017, 6},{0x002E, 6},
+    {0x002C, 6},{0x0008, 6},{0x0006, 5},{0x0001, 5}
+  },
+  {
+    {0x0000, 3},{0x000E, 5},{0x0017, 6},{0x002A, 6},
+    {0x0010, 7},{0x00F9,10},{0x00F8,10},{0x001E, 7},
+    {0x003F, 8},{0x0007, 3},{0x0006, 3},{0x0009, 4},
+    {0x0008, 4},{0x0006, 4},{0x000F, 5},{0x0005, 5},
+    {0x0016, 6},{0x0029, 6},{0x002B, 6},{0x0015, 6},
+    {0x0050, 7},{0x0011, 7},{0x007D, 9},{0x0004, 4},
+    {0x0017, 5},{0x0006, 5},{0x0014, 6},{0x002C, 6},
+    {0x002D, 6},{0x000E, 6},{0x0009, 6},{0x0051, 7}
+  },
+  {
+    {0x0002, 3},{0x0018, 5},{0x002F, 6},{0x000D, 5},
+    {0x0053, 7},{0x0295,10},{0x0294,10},{0x00A4, 8},
+    {0x007C, 8},{0x0000, 2},{0x0007, 3},{0x0009, 4},
+    {0x0008, 4},{0x001B, 5},{0x000C, 5},{0x0028, 6},
+    {0x006A, 7},{0x001E, 6},{0x001D, 6},{0x0069, 7},
+    {0x00D7, 8},{0x007D, 8},{0x014B, 9},{0x0019, 5},
+    {0x0016, 5},{0x002E, 6},{0x001C, 6},{0x002B, 6},
+    {0x002A, 6},{0x0068, 7},{0x003F, 7},{0x00D6, 8}
+  },
+  {
+    {0x0002, 3},{0x001B, 5},{0x000C, 5},{0x0018, 5},
+    {0x0029, 6},{0x007F, 8},{0x02F0,10},{0x0198, 9},
+    {0x0179, 9},{0x0000, 2},{0x0007, 3},{0x0009, 4},
+    {0x0008, 4},{0x001A, 5},{0x000D, 5},{0x002A, 6},
+    {0x0064, 7},{0x001E, 6},{0x0067, 7},{0x005F, 7},
+    {0x00CD, 8},{0x007E, 8},{0x02F1,10},{0x0016, 5},
+    {0x000E, 5},{0x002E, 6},{0x0065, 7},{0x002B, 6},
+    {0x0028, 6},{0x003E, 7},{0x00BD, 8},{0x0199, 9}
+  },
+  {
+    {0x0002, 3},{0x0007, 4},{0x0016, 5},{0x0006, 4},
+    {0x0036, 6},{0x005C, 7},{0x015D, 9},{0x015C, 9},
+    {0x02BF,10},{0x0000, 2},{0x0007, 3},{0x0009, 4},
+    {0x0008, 4},{0x0018, 5},{0x0034, 6},{0x002A, 6},
+    {0x005E, 7},{0x006A, 7},{0x0064, 7},{0x005D, 7},
+    {0x00CB, 8},{0x00AD, 8},{0x02BE,10},{0x0014, 5},
+    {0x0033, 6},{0x006E, 7},{0x005F, 7},{0x006F, 7},
+    {0x006B, 7},{0x00CA, 8},{0x00AC, 8},{0x015E, 9}
+  },
+  {
+    {0x000F, 4},{0x001D, 5},{0x0018, 5},{0x000B, 4},
+    {0x0019, 5},{0x0029, 6},{0x00D6, 8},{0x0551,11},
+    {0x0AA1,12},{0x0001, 2},{0x0000, 2},{0x0009, 4},
+    {0x0008, 4},{0x001B, 5},{0x0038, 6},{0x0028, 6},
+    {0x0057, 7},{0x006A, 7},{0x0068, 7},{0x0056, 7},
+    {0x00E5, 8},{0x0155, 9},{0x0AA0,12},{0x0073, 7},
+    {0x0069, 7},{0x00D7, 8},{0x00AB, 8},{0x00E4, 8},
+    {0x00A9, 8},{0x0151, 9},{0x0150, 9},{0x02A9,10}
+  },
+  {
+    {0x0008, 5},{0x0025, 7},{0x017A, 9},{0x02F7,10},
+    {0x0BDB,12},{0x17B4,13},{0x2F6B,14},{0x001D, 5},
+    {0x2F6A,14},{0x0008, 4},{0x0007, 4},{0x0001, 4},
+    {0x0002, 4},{0x000A, 4},{0x0006, 4},{0x0000, 4},
+    {0x001C, 5},{0x0009, 4},{0x000D, 4},{0x000F, 4},
+    {0x000C, 4},{0x0003, 4},{0x000A, 5},{0x0016, 5},
+    {0x0013, 6},{0x005D, 7},{0x0024, 7},{0x00BC, 8},
+    {0x005C, 7},{0x05EC,11},{0x000B, 5},{0x005F, 7}
+  },
+  {
+    {0x000F, 5},{0x0010, 6},{0x004B, 8},{0x00C6, 8},
+    {0x031D,10},{0x0C71,12},{0x0C70,12},{0x0001, 4},
+    {0x0C73,12},{0x0008, 4},{0x0009, 4},{0x0002, 4},
+    {0x0003, 4},{0x000B, 4},{0x0006, 4},{0x0000, 4},
+    {0x001C, 5},{0x0005, 4},{0x000D, 4},{0x000F, 4},
+    {0x000A, 4},{0x0019, 5},{0x0013, 6},{0x001D, 5},
+    {0x0030, 6},{0x0062, 7},{0x0024, 7},{0x004A, 8},
+    {0x018F, 9},{0x0C72,12},{0x000E, 5},{0x0011, 6}
+  },
+  {
+    {0x001B, 5},{0x0003, 6},{0x008D, 8},{0x0040, 7},
+    {0x0239,10},{0x0471,11},{0x08E0,12},{0x0003, 4},
+    {0x11C3,13},{0x000A, 4},{0x0009, 4},{0x0004, 4},
+    {0x0005, 4},{0x000E, 4},{0x0007, 4},{0x0001, 4},
+    {0x001E, 5},{0x0006, 4},{0x000C, 4},{0x000B, 4},
+    {0x0002, 4},{0x0000, 5},{0x0041, 7},{0x001F, 5},
+    {0x0022, 6},{0x0002, 6},{0x008F, 8},{0x008C, 8},
+    {0x011D, 9},{0x11C2,13},{0x001A, 5},{0x0021, 6}
+  },
+  {
+    {0x001F, 5},{0x0003, 6},{0x0003, 7},{0x0043, 7},
+    {0x000B, 9},{0x0015,10},{0x0051,12},{0x0003, 4},
+    {0x0050,12},{0x000D, 4},{0x000C, 4},{0x0004, 4},
+    {0x0006, 4},{0x000E, 4},{0x000A, 4},{0x0001, 4},
+    {0x001E, 5},{0x0005, 4},{0x0009, 4},{0x0007, 4},
+    {0x0011, 5},{0x0002, 6},{0x0004, 8},{0x0002, 4},
+    {0x002D, 6},{0x0020, 6},{0x0042, 7},{0x0001, 7},
+    {0x0000, 7},{0x0029,11},{0x0017, 5},{0x002C, 6}
+  },
+  {
+    {0x0003, 4},{0x001F, 6},{0x003A, 7},{0x005D, 7},
+    {0x0173, 9},{0x02E4,10},{0x172D,13},{0x0004, 4},
+    {0x172C,13},{0x000F, 4},{0x000E, 4},{0x0009, 4},
+    {0x0008, 4},{0x000C, 4},{0x000A, 4},{0x0001, 4},
+    {0x0016, 5},{0x0002, 4},{0x0005, 4},{0x001A, 5},
+    {0x002F, 6},{0x0038, 7},{0x05CA,11},{0x0006, 4},
+    {0x0037, 6},{0x001E, 6},{0x003B, 7},{0x0039, 7},
+    {0x00B8, 8},{0x0B97,12},{0x0000, 4},{0x0036, 6}
+  },
+  {
+    {0x0006, 4},{0x0037, 6},{0x005D, 7},{0x000C, 6},
+    {0x00B9, 8},{0x02E3,10},{0x05C4,11},{0x0004, 4},
+    {0x1715,13},{0x0000, 3},{0x000F, 4},{0x0008, 4},
+    {0x0007, 4},{0x000C, 4},{0x0009, 4},{0x001D, 5},
+    {0x0016, 5},{0x001C, 5},{0x001A, 5},{0x000B, 5},
+    {0x005E, 7},{0x0170, 9},{0x1714,13},{0x000A, 4},
+    {0x000A, 5},{0x0036, 6},{0x005F, 7},{0x001B, 7},
+    {0x001A, 7},{0x0B8B,12},{0x0002, 4},{0x0007, 5}
+  },
+  {
+    {0x000C, 4},{0x000B, 5},{0x0079, 7},{0x0022, 6},
+    {0x00F0, 8},{0x0119, 9},{0x0230,10},{0x001D, 5},
+    {0x08C4,12},{0x0001, 3},{0x0000, 3},{0x000A, 4},
+    {0x0009, 4},{0x000B, 4},{0x0007, 4},{0x001C, 5},
+    {0x003D, 6},{0x000D, 5},{0x0008, 5},{0x0015, 6},
+    {0x008D, 8},{0x118B,13},{0x118A,13},{0x000D, 4},
+    {0x0010, 5},{0x0009, 5},{0x0014, 6},{0x0047, 7},
+    {0x00F1, 8},{0x0463,11},{0x001F, 5},{0x000C, 5}
+  },
+  {
+    {0x0000, 3},{0x001A, 5},{0x0033, 6},{0x000C, 5},
+    {0x0046, 7},{0x01E3, 9},{0x03C5,10},{0x0017, 5},
+    {0x1E21,13},{0x0002, 3},{0x0001, 3},{0x0009, 4},
+    {0x000A, 4},{0x0007, 4},{0x001B, 5},{0x003D, 6},
+    {0x001B, 6},{0x0022, 6},{0x0079, 7},{0x00F0, 8},
+    {0x1E20,13},{0x1E23,13},{0x1E22,13},{0x000E, 4},
+    {0x0016, 5},{0x0018, 5},{0x0032, 6},{0x001A, 6},
+    {0x0047, 7},{0x0789,11},{0x001F, 5},{0x0010, 5}
+  },
+  {
+    {0x001D, 5},{0x0061, 7},{0x004E, 8},{0x009E, 9},
+    {0x027C,11},{0x09F5,13},{0x09F4,13},{0x0003, 4},
+    {0x0060, 7},{0x0000, 3},{0x000F, 4},{0x000B, 4},
+    {0x000A, 4},{0x0009, 4},{0x0005, 4},{0x000D, 5},
+    {0x0031, 6},{0x0008, 5},{0x0038, 6},{0x0012, 6},
+    {0x0026, 7},{0x013F,10},{0x04FB,12},{0x000D, 4},
+    {0x0002, 4},{0x000C, 5},{0x0039, 6},{0x001C, 6},
+    {0x000F, 5},{0x001D, 6},{0x0008, 4},{0x0019, 5}
+  },
+  {
+    {0x0007, 4},{0x0019, 6},{0x00AB, 8},{0x00AA, 8},
+    {0x0119,10},{0x0461,12},{0x0460,12},{0x001B, 5},
+    {0x0047, 8},{0x0001, 3},{0x0000, 3},{0x000C, 4},
+    {0x000B, 4},{0x0009, 4},{0x0005, 4},{0x000D, 5},
+    {0x0035, 6},{0x003D, 6},{0x003C, 6},{0x0018, 6},
+    {0x0022, 7},{0x008D, 9},{0x0231,11},{0x000E, 4},
+    {0x001F, 5},{0x0009, 5},{0x002B, 6},{0x0010, 6},
+    {0x0034, 6},{0x0054, 7},{0x0008, 4},{0x0014, 5}
+  },
+  {
+    {0x000C, 4},{0x0005, 5},{0x0008, 6},{0x005B, 7},
+    {0x004D, 9},{0x0131,11},{0x0261,12},{0x001A, 5},
+    {0x0012, 7},{0x0000, 3},{0x000F, 4},{0x000A, 4},
+    {0x0009, 4},{0x0006, 4},{0x001B, 5},{0x0006, 5},
+    {0x001C, 6},{0x002C, 6},{0x0015, 6},{0x005A, 7},
+    {0x0027, 8},{0x0099,10},{0x0260,12},{0x000E, 4},
+    {0x0004, 4},{0x000F, 5},{0x0007, 5},{0x001D, 6},
+    {0x000B, 5},{0x0014, 6},{0x0008, 4},{0x0017, 5}
+  },
+  {
+    {0x000F, 4},{0x0013, 5},{0x0075, 7},{0x0024, 6},
+    {0x0095, 8},{0x0251,10},{0x04A0,11},{0x0010, 5},
+    {0x00C8, 8},{0x0002, 3},{0x0001, 3},{0x0001, 4},
+    {0x0000, 4},{0x001A, 5},{0x0011, 5},{0x002C, 6},
+    {0x0065, 7},{0x0074, 7},{0x004B, 7},{0x00C9, 8},
+    {0x0129, 9},{0x0943,12},{0x0942,12},{0x0003, 3},
+    {0x000A, 4},{0x001C, 5},{0x0018, 5},{0x0033, 6},
+    {0x0017, 5},{0x002D, 6},{0x001B, 5},{0x003B, 6}
+  },
+  {
+    {0x0003, 3},{0x001A, 5},{0x002D, 6},{0x0038, 6},
+    {0x0028, 7},{0x0395,10},{0x0E51,12},{0x0037, 6},
+    {0x00E4, 8},{0x0001, 3},{0x0000, 3},{0x001F, 5},
+    {0x001E, 5},{0x0017, 5},{0x003A, 6},{0x0073, 7},
+    {0x002A, 7},{0x002B, 7},{0x0029, 7},{0x01CB, 9},
+    {0x0729,11},{0x1CA1,13},{0x1CA0,13},{0x0004, 3},
+    {0x000A, 4},{0x0004, 4},{0x0018, 5},{0x0036, 6},
+    {0x000B, 5},{0x002C, 6},{0x0019, 5},{0x003B, 6}
+  },
+  {
+    {0x0004, 3},{0x0004, 4},{0x003F, 6},{0x0017, 5},
+    {0x0075, 7},{0x01F5, 9},{0x07D1,11},{0x0017, 6},
+    {0x01F6, 9},{0x0001, 3},{0x0000, 3},{0x001B, 5},
+    {0x001A, 5},{0x000A, 5},{0x0032, 6},{0x0074, 7},
+    {0x00F8, 8},{0x00F9, 8},{0x01F7, 9},{0x03E9,10},
+    {0x0FA0,12},{0x1F43,13},{0x1F42,13},{0x0003, 3},
+    {0x000A, 4},{0x001E, 5},{0x001C, 5},{0x003B, 6},
+    {0x0018, 5},{0x0016, 6},{0x0016, 5},{0x0033, 6}
+  },
+  {
+    {0x0004, 3},{0x0007, 4},{0x0018, 5},{0x001E, 5},
+    {0x0036, 6},{0x0031, 7},{0x0177, 9},{0x0077, 7},
+    {0x0176, 9},{0x0001, 3},{0x0000, 3},{0x001A, 5},
+    {0x0019, 5},{0x003A, 6},{0x0019, 6},{0x005C, 7},
+    {0x00BA, 8},{0x0061, 8},{0x00C1, 9},{0x0180,10},
+    {0x0302,11},{0x0607,12},{0x0606,12},{0x0002, 3},
+    {0x000A, 4},{0x001F, 5},{0x001C, 5},{0x0037, 6},
+    {0x0016, 5},{0x0076, 7},{0x000D, 5},{0x002F, 6}
+  },
+  {
+    {0x0000, 3},{0x000A, 4},{0x001A, 5},{0x000C, 4},
+    {0x001D, 5},{0x0039, 6},{0x0078, 7},{0x005E, 7},
+    {0x0393,11},{0x0002, 3},{0x0001, 3},{0x0016, 5},
+    {0x000F, 5},{0x002E, 6},{0x005F, 7},{0x0073, 8},
+    {0x00E5, 9},{0x01C8,10},{0x0E4A,13},{0x1C97,14},
+    {0x1C96,14},{0x0E49,13},{0x0E48,13},{0x0004, 3},
+    {0x0006, 4},{0x001F, 5},{0x001B, 5},{0x001D, 6},
+    {0x0038, 6},{0x0038, 7},{0x003D, 6},{0x0079, 7}
+  },
+  {
+    {0x000B, 5},{0x002B, 7},{0x0054, 8},{0x01B7, 9},
+    {0x06D9,11},{0x0DB1,12},{0x0DB0,12},{0x0002, 4},
+    {0x00AB, 9},{0x0009, 4},{0x000A, 4},{0x0007, 4},
+    {0x0008, 4},{0x000F, 4},{0x000C, 4},{0x0003, 4},
+    {0x001D, 5},{0x0004, 4},{0x000B, 4},{0x0006, 4},
+    {0x001A, 5},{0x0003, 6},{0x00AA, 9},{0x0001, 4},
+    {0x0000, 5},{0x0014, 6},{0x006C, 7},{0x00DA, 8},
+    {0x0002, 6},{0x036D,10},{0x001C, 5},{0x0037, 6}
+  },
+  {
+    {0x001D, 5},{0x0004, 6},{0x00B6, 8},{0x006A, 8},
+    {0x05B9,11},{0x16E1,13},{0x16E0,13},{0x0007, 4},
+    {0x016F, 9},{0x000C, 4},{0x000D, 4},{0x0009, 4},
+    {0x0008, 4},{0x000F, 4},{0x000A, 4},{0x0003, 4},
+    {0x0017, 5},{0x0002, 4},{0x0004, 4},{0x001C, 5},
+    {0x002C, 6},{0x006B, 8},{0x0B71,12},{0x0005, 4},
+    {0x0003, 5},{0x001B, 6},{0x005A, 7},{0x0034, 7},
+    {0x0005, 6},{0x02DD,10},{0x0000, 4},{0x000C, 5}
+  },
+  {
+    {0x0003, 4},{0x007F, 7},{0x00A1, 8},{0x00A0, 8},
+    {0x020C,10},{0x0834,12},{0x106B,13},{0x0007, 4},
+    {0x0082, 8},{0x000E, 4},{0x000D, 4},{0x000B, 4},
+    {0x000C, 4},{0x0000, 3},{0x0009, 4},{0x0002, 4},
+    {0x0011, 5},{0x001E, 5},{0x0015, 5},{0x003E, 6},
+    {0x0040, 7},{0x041B,11},{0x106A,13},{0x0006, 4},
+    {0x000A, 5},{0x0029, 6},{0x007E, 7},{0x0051, 7},
+    {0x0021, 6},{0x0107, 9},{0x0004, 4},{0x000B, 5}
+  },
+  {
+    {0x0007, 4},{0x001B, 6},{0x00F6, 8},{0x00E9, 8},
+    {0x03A1,10},{0x0740,11},{0x0E82,12},{0x001F, 5},
+    {0x01EF, 9},{0x0001, 3},{0x0002, 3},{0x000B, 4},
+    {0x000C, 4},{0x000D, 4},{0x0008, 4},{0x001C, 5},
+    {0x0003, 5},{0x0012, 5},{0x0002, 5},{0x0075, 7},
+    {0x01D1, 9},{0x1D07,13},{0x1D06,13},{0x000A, 4},
+    {0x0013, 5},{0x003B, 6},{0x001A, 6},{0x007A, 7},
+    {0x003C, 6},{0x01EE, 9},{0x0000, 4},{0x000C, 5}
+  },
+  {
+    {0x000D, 4},{0x003D, 6},{0x0042, 7},{0x0037, 7},
+    {0x00D9, 9},{0x0362,11},{0x06C6,12},{0x001F, 5},
+    {0x0086, 8},{0x0001, 3},{0x0002, 3},{0x000C, 4},
+    {0x000B, 4},{0x000A, 4},{0x0001, 4},{0x000F, 5},
+    {0x0025, 6},{0x003C, 6},{0x001A, 6},{0x0087, 8},
+    {0x01B0,10},{0x0D8F,13},{0x0D8E,13},{0x000E, 4},
+    {0x0013, 5},{0x000C, 5},{0x0024, 6},{0x0020, 6},
+    {0x0011, 5},{0x006D, 8},{0x0000, 4},{0x000E, 5}
+  },
+  {
+    {0x0000, 3},{0x0012, 5},{0x0076, 7},{0x0077, 7},
+    {0x014D, 9},{0x0533,11},{0x14C9,13},{0x0013, 5},
+    {0x00A5, 8},{0x0002, 3},{0x0003, 3},{0x000B, 4},
+    {0x000C, 4},{0x0008, 4},{0x001A, 5},{0x002B, 6},
+    {0x0075, 7},{0x0074, 7},{0x00A7, 8},{0x0298,10},
+    {0x14C8,13},{0x14CB,13},{0x14CA,13},{0x000F, 4},
+    {0x001C, 5},{0x0007, 5},{0x002A, 6},{0x0028, 6},
+    {0x001B, 5},{0x00A4, 8},{0x0002, 4},{0x0006, 5}
+  },
+  {
+    {0x0002, 3},{0x001A, 5},{0x002B, 6},{0x003A, 6},
+    {0x00ED, 8},{0x0283,10},{0x0A0A,12},{0x0004, 5},
+    {0x00A1, 8},{0x0004, 3},{0x0003, 3},{0x000B, 4},
+    {0x000C, 4},{0x001F, 5},{0x0006, 5},{0x0077, 7},
+    {0x00A3, 8},{0x00A2, 8},{0x0140, 9},{0x1417,13},
+    {0x1416,13},{0x0A09,12},{0x0A08,12},{0x0000, 3},
+    {0x001E, 5},{0x0007, 5},{0x002A, 6},{0x0029, 6},
+    {0x001C, 5},{0x00EC, 8},{0x001B, 5},{0x0005, 5}
+  },
+  {
+    {0x0002, 3},{0x0002, 4},{0x0018, 5},{0x001D, 5},
+    {0x0035, 6},{0x00E4, 8},{0x01CF,11},{0x001D, 7},
+    {0x0072, 9},{0x0004, 3},{0x0005, 3},{0x0006, 4},
+    {0x0007, 4},{0x0006, 5},{0x0073, 7},{0x0038, 8},
+    {0x01CE,11},{0x039B,12},{0x0398,12},{0x0733,13},
+    {0x0732,13},{0x0735,13},{0x0734,13},{0x0000, 3},
+    {0x001F, 5},{0x001B, 5},{0x0034, 6},{0x000F, 6},
+    {0x001E, 5},{0x00E5, 8},{0x0019, 5},{0x0038, 6}
+  },
+  {
+    {0x0016, 5},{0x0050, 7},{0x0172, 9},{0x02E7,10},
+    {0x1732,13},{0x2E67,14},{0x2E66,14},{0x0006, 4},
+    {0x0051, 7},{0x0001, 3},{0x0000, 3},{0x000D, 4},
+    {0x000C, 4},{0x0009, 4},{0x001C, 5},{0x0009, 5},
+    {0x001C, 6},{0x001D, 6},{0x005D, 7},{0x00B8, 8},
+    {0x05CD,11},{0x1731,13},{0x1730,13},{0x000F, 4},
+    {0x0005, 4},{0x000F, 5},{0x0008, 5},{0x0029, 6},
+    {0x001D, 5},{0x002F, 6},{0x0008, 4},{0x0015, 5}
+  },
+  {
+    {0x0009, 4},{0x0021, 6},{0x0040, 7},{0x00AD, 8},
+    {0x02B0,10},{0x1589,13},{0x1588,13},{0x001C, 5},
+    {0x005F, 7},{0x0000, 3},{0x000F, 4},{0x000D, 4},
+    {0x000C, 4},{0x0006, 4},{0x0011, 5},{0x002A, 6},
+    {0x0057, 7},{0x005E, 7},{0x0041, 7},{0x0159, 9},
+    {0x0563,11},{0x158B,13},{0x158A,13},{0x0001, 3},
+    {0x0005, 4},{0x0014, 5},{0x003B, 6},{0x002E, 6},
+    {0x0004, 4},{0x003A, 6},{0x0007, 4},{0x0016, 5}
+  },
+  {
+    {0x000E, 4},{0x0007, 5},{0x0046, 7},{0x0045, 7},
+    {0x0064, 9},{0x032A,12},{0x0657,13},{0x0018, 5},
+    {0x000D, 6},{0x0000, 3},{0x000F, 4},{0x000A, 4},
+    {0x000B, 4},{0x001A, 5},{0x0036, 6},{0x0047, 7},
+    {0x0044, 7},{0x0018, 7},{0x0033, 8},{0x00CB,10},
+    {0x0656,13},{0x0329,12},{0x0328,12},{0x0002, 3},
+    {0x0006, 4},{0x0019, 5},{0x000E, 5},{0x0037, 6},
+    {0x0009, 4},{0x000F, 5},{0x0002, 4},{0x0010, 5}
+  },
+  {
+    {0x0003, 3},{0x0018, 5},{0x0023, 6},{0x0077, 7},
+    {0x0194, 9},{0x1956,13},{0x32AF,14},{0x003A, 6},
+    {0x0076, 7},{0x0002, 3},{0x0001, 3},{0x001F, 5},
+    {0x001E, 5},{0x0014, 5},{0x0022, 6},{0x0064, 7},
+    {0x0197, 9},{0x0196, 9},{0x032B,10},{0x0654,11},
+    {0x32AE,14},{0x1955,13},{0x1954,13},{0x0000, 3},
+    {0x0009, 4},{0x001C, 5},{0x0015, 5},{0x0010, 5},
+    {0x000D, 4},{0x0017, 5},{0x0016, 5},{0x0033, 6}
+  },
+  {
+    {0x0005, 3},{0x0006, 4},{0x003E, 6},{0x0010, 5},
+    {0x0048, 7},{0x093F,12},{0x24FA,14},{0x0032, 6},
+    {0x0067, 7},{0x0002, 3},{0x0001, 3},{0x001B, 5},
+    {0x001E, 5},{0x0034, 6},{0x0066, 7},{0x0092, 8},
+    {0x0126, 9},{0x024E,10},{0x049E,11},{0x49F7,15},
+    {0x49F6,15},{0x24F9,14},{0x24F8,14},{0x0000, 3},
+    {0x0007, 4},{0x0018, 5},{0x0011, 5},{0x003F, 6},
+    {0x000E, 4},{0x0013, 5},{0x0035, 6},{0x0025, 6}
+  },
+  {
+    {0x0005, 3},{0x0008, 4},{0x0012, 5},{0x001C, 5},
+    {0x001C, 6},{0x00EA, 9},{0x1D75,14},{0x001E, 6},
+    {0x0066, 7},{0x0001, 3},{0x0002, 3},{0x001B, 5},
+    {0x001A, 5},{0x001F, 6},{0x003B, 7},{0x0074, 8},
+    {0x01D6,10},{0x03AF,11},{0x1D74,14},{0x1D77,14},
+    {0x1D76,14},{0x0EB9,13},{0x0EB8,13},{0x000F, 4},
+    {0x0006, 4},{0x0013, 5},{0x003B, 6},{0x003A, 6},
+    {0x0000, 3},{0x0018, 5},{0x0032, 6},{0x0067, 7}
+  },
+  {
+    {0x0004, 3},{0x000A, 4},{0x001B, 5},{0x000C, 4},
+    {0x000D, 5},{0x00E6, 8},{0x0684,11},{0x0072, 7},
+    {0x00E7, 8},{0x0002, 3},{0x0001, 3},{0x0017, 5},
+    {0x0016, 5},{0x0018, 6},{0x00D1, 8},{0x01A0, 9},
+    {0x0686,11},{0x0D0F,12},{0x0D0A,12},{0x1A17,13},
+    {0x1A16,13},{0x1A1D,13},{0x1A1C,13},{0x000F, 4},
+    {0x001D, 5},{0x000E, 5},{0x0035, 6},{0x0038, 6},
+    {0x0000, 3},{0x000F, 5},{0x0019, 6},{0x0069, 7}
+  },
+  {
+    {0x0003, 3},{0x000C, 4},{0x001B, 5},{0x0000, 3},
+    {0x0003, 4},{0x002E, 6},{0x0051, 9},{0x00BC, 8},
+    {0x0053, 9},{0x0004, 3},{0x0002, 3},{0x0016, 5},
+    {0x0015, 5},{0x0015, 7},{0x0050, 9},{0x00A4,10},
+    {0x0294,12},{0x052B,13},{0x052A,13},{0x052D,13},
+    {0x052C,13},{0x052F,13},{0x052E,13},{0x000E, 4},
+    {0x001A, 5},{0x0004, 5},{0x0028, 6},{0x0029, 6},
+    {0x000F, 4},{0x000B, 6},{0x005F, 7},{0x00BD, 8}
+  },
+  {
+    {0x0003, 4},{0x0009, 6},{0x00D0, 8},{0x01A3, 9},
+    {0x0344,10},{0x0D14,12},{0x1A2B,13},{0x0004, 4},
+    {0x0015, 7},{0x0000, 3},{0x000F, 4},{0x000B, 4},
+    {0x000C, 4},{0x000E, 4},{0x0009, 4},{0x001B, 5},
+    {0x000A, 5},{0x0014, 5},{0x000D, 5},{0x002A, 6},
+    {0x0014, 7},{0x068B,11},{0x1A2A,13},{0x0008, 4},
+    {0x000B, 5},{0x002B, 6},{0x000B, 6},{0x0069, 7},
+    {0x0035, 6},{0x0008, 6},{0x0007, 4},{0x000C, 5}
+  },
+  {
+    {0x000A, 4},{0x003C, 6},{0x0032, 7},{0x0030, 7},
+    {0x00C5, 9},{0x0621,12},{0x0620,12},{0x001F, 5},
+    {0x0033, 7},{0x0001, 3},{0x0000, 3},{0x000E, 4},
+    {0x000D, 4},{0x000C, 4},{0x0004, 4},{0x000D, 5},
+    {0x0026, 6},{0x0027, 6},{0x0014, 6},{0x0063, 8},
+    {0x0189,10},{0x0623,12},{0x0622,12},{0x000B, 4},
+    {0x0012, 5},{0x003D, 6},{0x0022, 6},{0x0015, 6},
+    {0x000B, 5},{0x0023, 6},{0x0007, 4},{0x0010, 5}
+  },
+  {
+    {0x000F, 4},{0x000C, 5},{0x0043, 7},{0x0010, 6},
+    {0x0044, 8},{0x0114,10},{0x0455,12},{0x0018, 5},
+    {0x0023, 7},{0x0001, 3},{0x0000, 3},{0x000E, 4},
+    {0x000D, 4},{0x0009, 4},{0x0019, 5},{0x0009, 5},
+    {0x0017, 6},{0x0016, 6},{0x0042, 7},{0x008B, 9},
+    {0x0454,12},{0x0457,12},{0x0456,12},{0x000B, 4},
+    {0x0015, 5},{0x000A, 5},{0x0029, 6},{0x0020, 6},
+    {0x000D, 5},{0x0028, 6},{0x0007, 4},{0x0011, 5}
+  },
+  {
+    {0x0001, 3},{0x001A, 5},{0x0029, 6},{0x002A, 6},
+    {0x00A0, 8},{0x0285,10},{0x1425,13},{0x0002, 5},
+    {0x0000, 7},{0x0002, 3},{0x0003, 3},{0x000C, 4},
+    {0x000B, 4},{0x0008, 4},{0x0012, 5},{0x0001, 6},
+    {0x0051, 7},{0x0001, 7},{0x0143, 9},{0x0508,11},
+    {0x1424,13},{0x1427,13},{0x1426,13},{0x000F, 4},
+    {0x001C, 5},{0x0003, 5},{0x0037, 6},{0x002B, 6},
+    {0x0013, 5},{0x0036, 6},{0x001D, 5},{0x0001, 5}
+  },
+  {
+    {0x0004, 3},{0x001F, 5},{0x003D, 6},{0x0006, 5},
+    {0x0016, 7},{0x0053, 9},{0x014A,11},{0x0034, 6},
+    {0x002A, 8},{0x0002, 3},{0x0003, 3},{0x000B, 4},
+    {0x000C, 4},{0x001C, 5},{0x0037, 6},{0x0017, 7},
+    {0x002B, 8},{0x0028, 8},{0x00A4,10},{0x052D,13},
+    {0x052C,13},{0x052F,13},{0x052E,13},{0x0000, 3},
+    {0x001D, 5},{0x0007, 5},{0x0004, 5},{0x0035, 6},
+    {0x0014, 5},{0x0036, 6},{0x0015, 5},{0x003C, 6}
+  },
+  {
+    {0x0004, 3},{0x000A, 4},{0x0007, 5},{0x001D, 5},
+    {0x0009, 6},{0x01F3, 9},{0x07C7,11},{0x0008, 6},
+    {0x01F0, 9},{0x0003, 3},{0x0002, 3},{0x000D, 4},
+    {0x000C, 4},{0x0017, 5},{0x007D, 7},{0x01F2, 9},
+    {0x07C6,11},{0x07C5,11},{0x1F12,13},{0x3E27,14},
+    {0x3E26,14},{0x1F11,13},{0x1F10,13},{0x0000, 3},
+    {0x001E, 5},{0x0006, 5},{0x0039, 6},{0x0038, 6},
+    {0x003F, 6},{0x002C, 6},{0x0005, 5},{0x002D, 6}
+  },
+  {
+    {0x0002, 3},{0x0007, 4},{0x0018, 5},{0x0003, 4},
+    {0x0005, 5},{0x0035, 7},{0x004F, 9},{0x0012, 7},
+    {0x04E5,13},{0x0005, 3},{0x0004, 3},{0x000D, 4},
+    {0x000E, 4},{0x0033, 6},{0x0026, 8},{0x009D,10},
+    {0x04E4,13},{0x04E7,13},{0x04E6,13},{0x04E1,13},
+    {0x04E0,13},{0x04E3,13},{0x04E2,13},{0x0000, 3},
+    {0x001F, 5},{0x000C, 5},{0x003D, 6},{0x003C, 6},
+    {0x0032, 6},{0x0034, 7},{0x001B, 6},{0x0008, 6}
+  },
+  {
+    {0x0000, 3},{0x0004, 4},{0x001C, 5},{0x000F, 4},
+    {0x0002, 4},{0x0007, 5},{0x0075, 7},{0x00E8, 8},
+    {0x1D2A,13},{0x0005, 3},{0x0004, 3},{0x000D, 4},
+    {0x000C, 4},{0x0077, 7},{0x0E96,12},{0x3A57,14},
+    {0x3A56,14},{0x3A5D,14},{0x3A5C,14},{0x3A5F,14},
+    {0x3A5E,14},{0x1D29,13},{0x1D28,13},{0x0003, 3},
+    {0x0006, 5},{0x000A, 5},{0x002C, 7},{0x0017, 6},
+    {0x0076, 7},{0x01D3, 9},{0x03A4,10},{0x002D, 7}
+  },
+  {
+    {0x000A, 4},{0x0024, 6},{0x00BF, 8},{0x0085, 8},
+    {0x0211,10},{0x0842,12},{0x1087,13},{0x0018, 5},
+    {0x0020, 6},{0x0001, 3},{0x0002, 3},{0x000E, 4},
+    {0x000D, 4},{0x0007, 4},{0x0013, 5},{0x0025, 6},
+    {0x005E, 7},{0x0043, 7},{0x00BE, 8},{0x0109, 9},
+    {0x1086,13},{0x0841,12},{0x0840,12},{0x000F, 4},
+    {0x0001, 4},{0x0011, 5},{0x0000, 5},{0x002E, 6},
+    {0x0019, 5},{0x0001, 5},{0x0006, 4},{0x0016, 5}
+  },
+  {
+    {0x0002, 3},{0x000F, 5},{0x006F, 7},{0x0061, 7},
+    {0x0374,10},{0x1BA8,13},{0x3753,14},{0x0012, 5},
+    {0x0036, 6},{0x0000, 3},{0x0001, 3},{0x000A, 4},
+    {0x000B, 4},{0x001A, 5},{0x0031, 6},{0x0060, 7},
+    {0x00DC, 8},{0x01BB, 9},{0x06EB,11},{0x1BAB,13},
+    {0x3752,14},{0x3755,14},{0x3754,14},{0x000E, 4},
+    {0x0006, 4},{0x0013, 5},{0x000E, 5},{0x003E, 6},
+    {0x0008, 4},{0x001E, 5},{0x0019, 5},{0x003F, 6}
+  },
+  {
+    {0x0003, 3},{0x001C, 5},{0x0025, 6},{0x0024, 6},
+    {0x01DA, 9},{0x1DBD,13},{0x3B7C,14},{0x003C, 6},
+    {0x003D, 6},{0x0000, 3},{0x0001, 3},{0x000B, 4},
+    {0x000A, 4},{0x000B, 5},{0x0077, 7},{0x00EC, 8},
+    {0x03B6,10},{0x076E,11},{0x1DBF,13},{0x76FB,15},
+    {0x76FA,15},{0x3B79,14},{0x3B78,14},{0x000D, 4},
+    {0x001F, 5},{0x0013, 5},{0x000A, 5},{0x0008, 5},
+    {0x000C, 4},{0x0008, 4},{0x0009, 5},{0x003A, 6}
+  },
+  {
+    {0x0005, 3},{0x0003, 4},{0x0004, 5},{0x0010, 5},
+    {0x008F, 8},{0x0475,11},{0x11D1,13},{0x0079, 7},
+    {0x0027, 6},{0x0002, 3},{0x0003, 3},{0x0001, 4},
+    {0x0000, 4},{0x0026, 6},{0x0046, 7},{0x011C, 9},
+    {0x0477,11},{0x08ED,12},{0x11D0,13},{0x11D3,13},
+    {0x11D2,13},{0x11D9,13},{0x11D8,13},{0x000D, 4},
+    {0x001F, 5},{0x0012, 5},{0x0005, 5},{0x003D, 6},
+    {0x000C, 4},{0x000E, 4},{0x0022, 6},{0x0078, 7}
+  },
+  {
+    {0x0005, 3},{0x000C, 4},{0x001B, 5},{0x0000, 4},
+    {0x0006, 6},{0x03E2,10},{0x3E3D,14},{0x000F, 7},
+    {0x0034, 6},{0x0003, 3},{0x0002, 3},{0x001E, 5},
+    {0x001D, 5},{0x007D, 7},{0x01F0, 9},{0x07C6,11},
+    {0x3E3C,14},{0x3E3F,14},{0x3E3E,14},{0x3E39,14},
+    {0x3E38,14},{0x3E3B,14},{0x3E3A,14},{0x0008, 4},
+    {0x001C, 5},{0x0002, 5},{0x003F, 6},{0x0035, 6},
+    {0x0009, 4},{0x0001, 3},{0x000E, 7},{0x00F9, 8}
+  },
+  {
+    {0x0004, 3},{0x000B, 4},{0x0001, 4},{0x000A, 4},
+    {0x001E, 6},{0x00E0, 9},{0x0E1E,13},{0x0071, 8},
+    {0x0039, 7},{0x0007, 3},{0x0006, 3},{0x000D, 5},
+    {0x000C, 5},{0x0020, 7},{0x01C2,10},{0x1C3F,14},
+    {0x1C3E,14},{0x0E19,13},{0x0E18,13},{0x0E1B,13},
+    {0x0E1A,13},{0x0E1D,13},{0x0E1C,13},{0x0000, 4},
+    {0x0009, 5},{0x001D, 6},{0x001F, 6},{0x0011, 6},
+    {0x0005, 4},{0x0001, 3},{0x0043, 8},{0x0042, 8}
+  },
+  {
+    {0x0004, 3},{0x000D, 4},{0x0007, 4},{0x0002, 3},
+    {0x0014, 5},{0x016C, 9},{0x16D1,13},{0x02DF,10},
+    {0x016E, 9},{0x0000, 2},{0x0007, 3},{0x002C, 6},
+    {0x002B, 6},{0x02DE,10},{0x16D0,13},{0x16D3,13},
+    {0x16D2,13},{0x2DB5,14},{0x2DB4,14},{0x2DB7,14},
+    {0x2DB6,14},{0x16D9,13},{0x16D8,13},{0x000C, 5},
+    {0x002A, 6},{0x005A, 7},{0x001B, 6},{0x001A, 6},
+    {0x0017, 5},{0x000C, 4},{0x05B7,11},{0x05B5,11}
+  },
+  {
+    {0x0002, 2},{0x000F, 4},{0x001C, 5},{0x000C, 4},
+    {0x003B, 6},{0x01AC, 9},{0x1AD8,13},{0x35B3,14},
+    {0x35B2,14},{0x0001, 2},{0x0000, 2},{0x0069, 7},
+    {0x0068, 7},{0x35BD,14},{0x35BC,14},{0x35BF,14},
+    {0x35BE,14},{0x35B9,14},{0x35B8,14},{0x35BB,14},
+    {0x35BA,14},{0x35B5,14},{0x35B4,14},{0x01A9, 9},
+    {0x01A8, 9},{0x035A,10},{0x00D7, 8},{0x00D5, 8},
+    {0x003A, 6},{0x001B, 5},{0x35B7,14},{0x35B6,14}
+  },
+  {
+    {0x0000, 3},{0x0010, 5},{0x0072, 7},{0x0071, 7},
+    {0x0154, 9},{0x0AAB,12},{0x0AA8,12},{0x0014, 5},
+    {0x0070, 7},{0x0002, 3},{0x0003, 3},{0x000C, 4},
+    {0x000B, 4},{0x0003, 4},{0x0011, 5},{0x0073, 7},
+    {0x0054, 7},{0x00AB, 8},{0x02AB,10},{0x1553,13},
+    {0x1552,13},{0x1555,13},{0x1554,13},{0x000D, 4},
+    {0x001E, 5},{0x0012, 5},{0x003E, 6},{0x002B, 6},
+    {0x0002, 4},{0x003F, 6},{0x001D, 5},{0x0013, 5}
+  },
+  {
+    {0x0003, 3},{0x001F, 5},{0x0029, 6},{0x003D, 6},
+    {0x000C, 7},{0x0069,10},{0x0345,13},{0x0002, 5},
+    {0x0028, 6},{0x0002, 3},{0x0001, 3},{0x000E, 4},
+    {0x000C, 4},{0x0015, 5},{0x0007, 6},{0x001B, 8},
+    {0x006B,10},{0x006A,10},{0x0344,13},{0x0347,13},
+    {0x0346,13},{0x01A1,12},{0x01A0,12},{0x000B, 4},
+    {0x001A, 5},{0x0012, 5},{0x0000, 5},{0x003C, 6},
+    {0x0008, 4},{0x001B, 5},{0x0013, 5},{0x0001, 5}
+  },
+  {
+    {0x0004, 3},{0x0004, 4},{0x003F, 6},{0x0014, 5},
+    {0x0056, 7},{0x015C, 9},{0x15D5,13},{0x003C, 6},
+    {0x002A, 6},{0x0000, 3},{0x0001, 3},{0x000E, 4},
+    {0x000D, 4},{0x000C, 5},{0x00AF, 8},{0x02BB,10},
+    {0x15D4,13},{0x15D7,13},{0x15D6,13},{0x15D1,13},
+    {0x15D0,13},{0x15D3,13},{0x15D2,13},{0x000B, 4},
+    {0x0019, 5},{0x000D, 5},{0x003E, 6},{0x0031, 6},
+    {0x0007, 4},{0x0005, 4},{0x003D, 6},{0x0030, 6}
+  },
+  {
+    {0x0005, 3},{0x0008, 4},{0x001A, 5},{0x0000, 4},
+    {0x0036, 6},{0x0011, 8},{0x0106,12},{0x000A, 7},
+    {0x006E, 7},{0x0002, 3},{0x0003, 3},{0x0003, 4},
+    {0x0002, 4},{0x006F, 7},{0x0021, 9},{0x020F,13},
+    {0x020E,13},{0x0101,12},{0x0100,12},{0x0103,12},
+    {0x0102,12},{0x0105,12},{0x0104,12},{0x000C, 4},
+    {0x001E, 5},{0x0003, 5},{0x003E, 6},{0x003F, 6},
+    {0x0009, 4},{0x000E, 4},{0x000B, 7},{0x0009, 7}
+  },
+  {
+    {0x0002, 3},{0x000E, 4},{0x001E, 5},{0x000C, 4},
+    {0x001F, 5},{0x006E, 7},{0x00AD,10},{0x00AF,10},
+    {0x0014, 7},{0x0004, 3},{0x0003, 3},{0x001A, 5},
+    {0x0017, 5},{0x002A, 8},{0x0576,13},{0x0AEF,14},
+    {0x0AEE,14},{0x0571,13},{0x0570,13},{0x0573,13},
+    {0x0572,13},{0x0575,13},{0x0574,13},{0x0003, 4},
+    {0x0016, 5},{0x0004, 5},{0x0036, 6},{0x000B, 6},
+    {0x000A, 4},{0x0000, 3},{0x006F, 7},{0x00AC,10}
+  },
+  {
+    {0x0004, 3},{0x0005, 4},{0x0003, 3},{0x0001, 3},
+    {0x0004, 4},{0x002F, 6},{0x0526,11},{0x1495,13},
+    {0x00A6, 8},{0x0007, 3},{0x0006, 3},{0x002D, 6},
+    {0x002C, 6},{0x1494,13},{0x1497,13},{0x1496,13},
+    {0x1491,13},{0x1490,13},{0x1493,13},{0x1492,13},
+    {0x293D,14},{0x293C,14},{0x293F,14},{0x0000, 3},
+    {0x0028, 6},{0x00A5, 8},{0x0148, 9},{0x00A7, 8},
+    {0x002E, 6},{0x0015, 5},{0x0A4E,12},{0x293E,14}
+  },
+  {
+    {0x0004, 3},{0x0005, 4},{0x0003, 3},{0x0001, 3},
+    {0x0004, 4},{0x002F, 6},{0x0526,11},{0x1495,13},
+    {0x00A6, 8},{0x0007, 3},{0x0006, 3},{0x002D, 6},
+    {0x002C, 6},{0x1494,13},{0x1497,13},{0x1496,13},
+    {0x1491,13},{0x1490,13},{0x1493,13},{0x1492,13},
+    {0x293D,14},{0x293C,14},{0x293F,14},{0x0000, 3},
+    {0x0028, 6},{0x00A5, 8},{0x0148, 9},{0x00A7, 8},
+    {0x002E, 6},{0x0015, 5},{0x0A4E,12},{0x293E,14}
+  },
+  {
+    {0x0004, 3},{0x0005, 4},{0x0003, 3},{0x0001, 3},
+    {0x0004, 4},{0x002F, 6},{0x0526,11},{0x1495,13},
+    {0x00A6, 8},{0x0007, 3},{0x0006, 3},{0x002D, 6},
+    {0x002C, 6},{0x1494,13},{0x1497,13},{0x1496,13},
+    {0x1491,13},{0x1490,13},{0x1493,13},{0x1492,13},
+    {0x293D,14},{0x293C,14},{0x293F,14},{0x0000, 3},
+    {0x0028, 6},{0x00A5, 8},{0x0148, 9},{0x00A7, 8},
+    {0x002E, 6},{0x0015, 5},{0x0A4E,12},{0x293E,14}
+  },
+  {
+    {0x0003, 3},{0x0011, 5},{0x0020, 6},{0x0074, 7},
+    {0x010D, 9},{0x0863,12},{0x0860,12},{0x000A, 5},
+    {0x0075, 7},{0x0001, 3},{0x0000, 3},{0x000B, 4},
+    {0x000A, 4},{0x0018, 5},{0x0038, 6},{0x0042, 7},
+    {0x010F, 9},{0x010E, 9},{0x0219,10},{0x10C3,13},
+    {0x10C2,13},{0x10C5,13},{0x10C4,13},{0x000F, 4},
+    {0x0004, 4},{0x0019, 5},{0x000B, 5},{0x0039, 6},
+    {0x0009, 4},{0x001B, 5},{0x001A, 5},{0x003B, 6}
+  },
+  {
+    {0x0005, 3},{0x0001, 4},{0x003E, 6},{0x0001, 5},
+    {0x00E2, 8},{0x1C6F,13},{0x38D9,14},{0x0039, 6},
+    {0x001F, 6},{0x0002, 3},{0x0001, 3},{0x0009, 4},
+    {0x0008, 4},{0x0000, 5},{0x0070, 7},{0x01C7, 9},
+    {0x038C,10},{0x071A,11},{0x38D8,14},{0x38DB,14},
+    {0x38DA,14},{0x38DD,14},{0x38DC,14},{0x000D, 4},
+    {0x001D, 5},{0x000E, 5},{0x003F, 6},{0x003C, 6},
+    {0x000C, 4},{0x0006, 4},{0x003D, 6},{0x001E, 6}
+  },
+  {
+    {0x0006, 3},{0x000B, 4},{0x0011, 5},{0x001E, 5},
+    {0x0074, 7},{0x03AA,10},{0x1D5C,13},{0x0001, 6},
+    {0x0021, 6},{0x0001, 3},{0x0002, 3},{0x0007, 4},
+    {0x0006, 4},{0x003E, 6},{0x00EB, 8},{0x01D4, 9},
+    {0x0EAF,12},{0x3ABB,14},{0x3ABA,14},{0x1D59,13},
+    {0x1D58,13},{0x1D5B,13},{0x1D5A,13},{0x000A, 4},
+    {0x001C, 5},{0x0001, 5},{0x003F, 6},{0x003B, 6},
+    {0x0001, 4},{0x0009, 4},{0x0020, 6},{0x0000, 6}
+  },
+  {
+    {0x0004, 3},{0x000A, 4},{0x0017, 5},{0x0004, 4},
+    {0x0016, 6},{0x016A, 9},{0x16B1,13},{0x0017, 7},
+    {0x005B, 7},{0x0006, 3},{0x0007, 3},{0x0001, 4},
+    {0x0000, 4},{0x000A, 6},{0x02D7,10},{0x0B5A,12},
+    {0x16B0,13},{0x16B3,13},{0x16B2,13},{0x2D6D,14},
+    {0x2D6C,14},{0x2D6F,14},{0x2D6E,14},{0x0006, 4},
+    {0x000A, 5},{0x0004, 5},{0x002C, 6},{0x0017, 6},
+    {0x0003, 4},{0x0007, 4},{0x0016, 7},{0x00B4, 8}
+  },
+  {
+    {0x0005, 3},{0x000D, 4},{0x0005, 4},{0x0009, 4},
+    {0x0033, 6},{0x0193, 9},{0x192C,13},{0x0061, 8},
+    {0x0031, 7},{0x0000, 2},{0x0007, 3},{0x0010, 5},
+    {0x0011, 5},{0x00C8, 8},{0x192F,13},{0x325B,14},
+    {0x325A,14},{0x1929,13},{0x1928,13},{0x192B,13},
+    {0x192A,13},{0x325D,14},{0x325C,14},{0x0018, 5},
+    {0x001A, 6},{0x001B, 6},{0x0065, 7},{0x0019, 6},
+    {0x0004, 4},{0x0007, 4},{0x0060, 8},{0x0324,10}
+  },
+  {
+    {0x0006, 3},{0x0000, 3},{0x0002, 4},{0x000F, 4},
+    {0x0039, 6},{0x01D9, 9},{0x1D82,13},{0x0761,11},
+    {0x03BE,10},{0x0001, 2},{0x0002, 2},{0x000F, 6},
+    {0x000E, 6},{0x0762,11},{0x3B07,14},{0x3B06,14},
+    {0x3B1D,14},{0x3B1C,14},{0x3B1F,14},{0x3B1E,14},
+    {0x3B19,14},{0x3B18,14},{0x3B1B,14},{0x0038, 6},
+    {0x01DE, 9},{0x00ED, 8},{0x03BF,10},{0x00EE, 8},
+    {0x003A, 6},{0x0006, 5},{0x0EC0,12},{0x3B1A,14}
+  },
+  {
+    {0x0000, 2},{0x0002, 3},{0x000F, 5},{0x0006, 4},
+    {0x001C, 6},{0x01D0,10},{0x0E8C,13},{0x1D1B,14},
+    {0x1D1A,14},{0x0003, 2},{0x0002, 2},{0x00EA, 9},
+    {0x00E9, 9},{0x0E89,13},{0x0E88,13},{0x0E8B,13},
+    {0x0E8A,13},{0x1D65,14},{0x1D64,14},{0x1D67,14},
+    {0x1D66,14},{0x1D61,14},{0x1D60,14},{0x03AD,11},
+    {0x1D63,14},{0x1D62,14},{0x1D1D,14},{0x1D1C,14},
+    {0x003B, 7},{0x01D7,10},{0x1D1F,14},{0x1D1E,14}
+  },
+  {
+    {0x0002, 2},{0x000F, 4},{0x001C, 5},{0x000C, 4},
+    {0x003B, 6},{0x01AC, 9},{0x1AD8,13},{0x35B3,14},
+    {0x35B2,14},{0x0001, 2},{0x0000, 2},{0x0069, 7},
+    {0x0068, 7},{0x35BD,14},{0x35BC,14},{0x35BF,14},
+    {0x35BE,14},{0x35B9,14},{0x35B8,14},{0x35BB,14},
+    {0x35BA,14},{0x35B5,14},{0x35B4,14},{0x01A9, 9},
+    {0x01A8, 9},{0x035A,10},{0x00D7, 8},{0x00D5, 8},
+    {0x003A, 6},{0x001B, 5},{0x35B7,14},{0x35B6,14}
+  }
+};
+  

Added: experimental/j/Elphel333/common/utils.c
===================================================================
--- experimental/j/Elphel333/common/utils.c	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/common/utils.c	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,181 @@
+/******************************************************************************
+This is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+	
+******************************************************************************/
+// Streamer for Elphel JPEG camera 313 input device
+// Copyright (c) 2004 Andy Latin aka Landy, Dmitry Latin aka ipfreely
+// All rights reserved.
+//
+// http://andy.qnx.org.ru
+// mail to:  
+// andy at qnx.org.ru   
+// landy at mail333.com
+/////////////////////////////////////////////////////////////////////////////
+
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <time.h>
+#include <sys/time.h>
+
+#include "defines.h"
+
+
+///////////////// Time functions ///////////////////////////////////////
+
+int usec_sleep(int usec_delay)
+{
+#ifdef HAVE_NANOSLEEP
+    struct timespec ts;
+    ts.tv_sec  =  usec_delay / TimestampTicks;
+    ts.tv_nsec = (usec_delay % TimestampTicks) * 1000;
+    return nanosleep(&ts, NULL);
+#else
+    return usleep(usec_delay);
+#endif
+}
+
+// Returns current time in microseconds
+Timestamp GetTimestamp()
+{
+        struct timeval tv;
+        gettimeofday(&tv, NULL);
+        return (tv.tv_sec * TimestampTicks) + tv.tv_usec;
+}
+
+// Returns current time in milliseconds
+Timestamp GetTimerMs(void)
+{
+     return GetTimestamp()/1000;
+}  
+
+
+static Timestamp RelativeTime=0;
+
+// Returns time spent between now and last call in microseconds
+Timestamp GetRelativeTime()
+{
+  Timestamp t,r;
+
+  t=GetTimestamp();
+  r=t-RelativeTime;
+  RelativeTime=t;
+  return r;
+}
+
+// Initialize timer, must be called at least once at start
+void InitTimer()
+{
+  GetRelativeTime();
+}
+
+
+static  int once = 0;
+
+void SeedRandom(void)
+{
+   if (!once) {
+	srandom(time(NULL));
+	once = 1;
+   }
+}
+
+uint32_t GetRandomMcastAddress(void) 
+{
+	SeedRandom();
+
+	// pick a random number in the multicast range
+	uint32_t mcast = ((random() & 0x0FFFFFFF) | 0xE0000000);
+
+	// screen out undesirable values
+	// introduces small biases in the results
+
+	// stay away from 224.0.0.x
+	if ((mcast & 0x0FFFFF00) == 0) {
+		mcast |= 0x00000100;	// move to 224.0.1
+	} 
+
+	// stay out of SSM range 232.x.x.x
+	// user should explictly select this if they want SSM
+	if ((mcast & 0xFF000000) == 232) {
+		mcast |= 0x01000000;	// move to 233
+	}
+
+	// stay away from .0 .1 and .255
+	if ((mcast & 0xFF) == 0 || (mcast & 0xFF) == 1 
+	  || (mcast & 0xFF) == 255) {
+		mcast = (mcast & 0xFFFFFFF0) | 0x4;	// move to .4 or .244
+	}
+
+  return htonl(mcast);
+}
+
+uint16_t GetRandomPortBlock(void) 
+{
+	SeedRandom();
+
+	// Get random block of 4 port numbers above 20000
+	return (uint16_t)(20000 + ((random() >> 18) << 2));
+}
+
+
+///////////////////// Rtp time functions /////////////////////
+
+static Timestamp StartTimestamp = 0;
+static Timestamp RtpTimestampOffset =0;
+
+RtpTimestamp TimestampToRtp(Timestamp t)
+{
+  if (StartTimestamp !=0) {
+	    return (uint32_t)(((t - StartTimestamp) 
+		* TimeScale) / TimestampTicks)
+	      	+ RtpTimestampOffset;
+	  }
+	  StartTimestamp = t;
+	  return 0;
+	}
+
+static const u_int32_t SECS_BETWEEN_1900_1970 = 2208988800U;
+
+Timestamp TimestampToNtp(Timestamp t) 
+{
+	// low order ntp 32 bits is 2 ^ 32 -1 ticks per sec
+	register uint32_t usecs = t % TimestampTicks;
+	return (((t / TimestampTicks) + SECS_BETWEEN_1900_1970) << 32)
+		| ((usecs << 12) + (usecs << 8) - ((usecs * 3650) >> 6));
+}
+
+void HexDump(
+        u_int8_t* pBytes, u_int32_t numBytes)
+{
+	uint32_t i;
+
+        printf("<%u bytes> ", numBytes);
+        for (i = 0; i < numBytes; i++) {
+                if ((i % 16) == 0 && numBytes > 16) {
+                        printf("\n");
+                }
+                printf("%02x ", pBytes[i]);
+        }
+        printf("\n");
+}
+#if 0
+void main(){
+  float t=0;
+  InitTimer();
+  while(1){ t+=GetRelativeTime();printf("time= %10.6f\r",t);fflush(stdout); }
+}
+#endif
+

Added: experimental/j/Elphel333/http/.target-makefrag
===================================================================
--- experimental/j/Elphel333/http/.target-makefrag	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/http/.target-makefrag	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1 @@
+AXIS_BUILDTYPE=cris-axis-linux-gnu

Added: experimental/j/Elphel333/http/Makefile
===================================================================
--- experimental/j/Elphel333/http/Makefile	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/http/Makefile	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,34 @@
+#
+# Makefile for the Elphel streamer.
+# This probably requires GNU make.
+#
+AXIS_USABLE_LIBS = UCLIBC GLIBC
+include $(AXIS_TOP_DIR)/tools/build/Rules.axis
+
+THEORACOMMON=../common
+THEORACOMMON_OBJS=$(THEORACOMMON)/oggtheora.o $(THEORACOMMON)/utils.o
+
+DEFS   = -DHAVE_CONFIG_H
+CFLAGS = -O2 -W  -Wwrite-strings -Wbad-function-cast -Wmissing-prototypes -Wcast-qual -Wmissing-declarations  $(DEFS) -I$(THEORACOMMON)
+LIBS   = -lm 
+
+LD	= ld-cris
+
+TARGET = theora.cgi
+OBJS   = TheoraHTTP.o
+SRCS   = $(OBJS:%.o=%.c)
+
+all: $(TARGET)
+
+$(TARGET): $(OBJS) $(THEORACOMMON_OBJS)
+	 $(CC) $(CFLAGS) -o $@ $(OBJS) $(THEORACOMMON_OBJS) $(LIBS)
+	 strip-cris $@
+
+.c.o:
+	$(CC) $(CFLAGS) $(INC) -c $<
+
+$(THEORACOMMON_OBJS): 
+	cd $(THEORACOMMON) && $(MAKE)
+
+clean:
+	-rm -f *.o $(OBJS) $(TARGET)

Added: experimental/j/Elphel333/http/README
===================================================================
--- experimental/j/Elphel333/http/README	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/http/README	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,8 @@
+make sure you souced init_env
+
+./.target-makefrag should be
+AXIS_BUILDTYPE=cris-axis-linux-gnu
+
+if not run: make cris-axis-linux-gnu
+
+after that run make to build TheoraHTTP

Added: experimental/j/Elphel333/http/TheoraHTTP.c
===================================================================
--- experimental/j/Elphel333/http/TheoraHTTP.c	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/http/TheoraHTTP.c	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,461 @@
+/******************************************************************************
+This is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+    
+******************************************************************************/
+// HTTP Ogg Streamer for Elphel Camera 333 input device
+// Copyright (c) 2005 Jan Gerber
+/////////////////////////////////////////////////////////////////////////////
+#include <sys/time.h>
+#include <sys/mman.h>           /* mmap */
+#include <sys/ioctl.h>
+#include <sys/fcntl.h>
+#include <ctype.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <getopt.h>
+#include <errno.h>
+
+
+#include "c313a.h"
+
+#include "defines.h"
+#include "oggtheora.h"
+
+#define D(x) 
+
+#define HDR_INTERVAL   100   // send headers every 4 s for  25 fps
+
+///////////////////// GLOBAL DATA ///////////////////
+int                 mTimeinterval = 40000;  // default for 25 fps
+const char          mmapFileName[]= "/var/tmp/mmap_strm";
+strm_data_t         *strm_data;
+static strm_data_t  strm_data_par;
+int                 hdr_size;
+/////////////// OggTheora data///////////////////////
+int                 kfgshiftm=9;
+len_data_t          packets[6];
+u_int32_t           header_lengths[6];
+uint8_t             *b_headers;
+/////////////////////////////////////////////////////
+
+
+static void
+usage()
+{
+    printf("\n");
+    printf("\tTheora HTTP streamer for Elphel Camera model 333. \n");
+    printf("\tBased on TheoraStrm 0.5 (RTP streamer)\n");
+  
+    printf("\n\tUsage: TheoraStrm [-f <fps>] [-a <address>] [-p <port>] [-w] [-h]\n\n");
+    printf("\t\t[-w] - use WEB interface for manage streamer\n\n");
+
+    printf("\t If used WEB interface for manage of streamer, options enumerated\n");
+    printf("\t below can be changed from browser.\n\n");
+    
+    printf("\t\t[-f<fps>] - max values fps(frame per second), default 25.\n");
+    printf("\t\tRange from 1 to 30 fps.\n");
+    printf("\t\t[-a<address>] - Unicast or multicast address for streaming RTP\n");
+    printf("\t\t\tDefault 239.0.0.1\n");
+
+    printf("\t\t[-p<port>] - port for streaming data. Must be EVEN!\n");
+    printf("\t\t\tDefault 20000.\n");
+
+    printf("\t\t[-k<password>] - set encryption mode with key <password> (DES)\n");
+    printf("\t\t[-h]  - this help\n\n");
+  exit(-1);
+}
+
+int make_OggTheoraHdrs(const char *headers_filename)
+{
+     FILE      *headers_file;
+     u_int32_t  num_headers;
+     int        i,r;
+
+     //rtp foo, has to go
+    //struct stat     f_stat;
+
+    if ((headers_file = fopen(headers_filename, "r"))==NULL) {
+        fprintf(stderr,"error opening file %s for reading - error = %d (%s)\n",
+                        headers_filename,errno,strerror(errno)); 
+        return -1;
+    }
+    if (fread (&num_headers,   4, 1, headers_file)<1) 
+        return -4;
+    if (num_headers!=6) 
+        return -5;
+    if (fread (header_lengths, 4, 6, headers_file)<6) 
+        return -5;
+    if (fread (&kfgshiftm,     4, 1, headers_file)<1) 
+        return -5;
+
+    for (i=0;i<3;i++) 
+        packets[i].len=header_lengths[i]>>3; // now - in bytes
+    for (i=3;i<6;i++) 
+        packets[i].len=header_lengths[i]; // these are needed to be in bits
+    for (i=0;i<6;i++) {
+        header_lengths[i]=(header_lengths[i]+31)>>5;
+        packets[i].data=malloc(header_lengths[i]<<2);
+        if (((r=fread (packets[i].data, 4, header_lengths[i], headers_file))) < (int)header_lengths[i]) {
+           fprintf(stderr, "i=%d, fread returned %d, wanted - %d\n",
+                           i, r,header_lengths[i]);
+           return -6;
+        }     
+    }
+    fclose(headers_file);
+// now some RTP foo that is in no way RFC
+/*
+    stat(headers_filename,&f_stat);
+    hdr_size = f_stat.st_size;
+    //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+    // draft realese - TODO for RFC future
+    b_headers = (uint8_t *)malloc(hdr_size+1);
+    if ((headers_file = fopen(headers_filename, "r"))==NULL) {
+        fprintf(stderr,"error opening file %s for reading - error = %d (%s)\n",
+                       headers_filename,errno,strerror(errno)); 
+        return -1;
+    }
+    // put data into memory buffer
+    if (fread (b_headers+1,   hdr_size, 1, headers_file)<1) 
+        return -7;
+    hdr_size +=1;
+    fclose(headers_file);
+*/
+    return 0;    
+}
+
+static void main_loop() {
+    uint64_t    time_frame = 0;
+    uint32_t    len=0;
+    int         delta, nframe;
+    char        headers_filename[]="/tmp/headers";
+    char        controlfn[]="/dev/ccam_img";
+
+    int         devfd, i;
+    int         acq_data;
+    int         nframes_total, nframes_inter_full, nframes_inter_masked;
+    int         time_slow;
+    u_int8_t    *ccam_dma, *dp = NULL;
+    u_int32_t   *ccam_dma_index;
+    int         circindex_fd;
+    int         circbuf_fd;
+    int         circbuf_size;
+    int         circindex_size;
+ 
+    int         wp,wp0,frame_start = 0,frame_end,frame_type= 0,a_ready;
+    uint32_t    frame_length;
+    int         next_frame_start, frame_no =0,last_page_flags = 0;
+
+    //FIXME, use some random number here.
+    u_int32_t   stream_serial=0x114a36b7;
+    int         page = 0;
+    
+    //FIXME where does this have to go?                    
+    u_int64_t  granule=0;
+    int header_length;
+    ogg_header_t header;
+    int page_size=8192;
+
+
+    a_ready = 0; 
+    circindex_fd = open("/dev/circindex", O_RDWR);
+    if (circindex_fd<0) { // check control OK
+        fprintf(stderr,"Error opening %s\n", "/dev/circindex");
+        return ;
+    }
+    // find total buffer length
+    circindex_size=lseek(circindex_fd,0,2);
+    ccam_dma_index = (u_int32_t *) mmap(0, circindex_size, PROT_READ, MAP_SHARED, circindex_fd, 0);
+    if(ccam_dma_index ==((u_int32_t  *) -1)) {
+        fprintf(stderr,"Error in mmap %s\r\n","/dev/circindex");
+        close(circindex_fd);
+        return ;
+    }
+
+    circbuf_fd = open("/dev/circbuf", O_RDWR);
+    if (circbuf_fd<0) { // check control OK
+        fprintf(stderr,"Error opening %s\n", "/dev/circbuf");
+        close(circindex_fd);
+        return ;
+    }
+    // find total buffer length
+    circbuf_size=lseek(circbuf_fd,0,2);
+    fprintf(stderr,"circbuf stores %d long values (%d bytes)\n",
+                                                (circbuf_size>>2),circbuf_size);
+    ccam_dma = 
+        (u_int8_t *) mmap(0, circbuf_size, PROT_READ, MAP_SHARED, circbuf_fd, 0);
+    if(ccam_dma ==((u_int8_t  *) -1)) {
+        fprintf(stderr,"Error in mmap %s\r\n","/dev/circbuf");
+        close(circindex_fd);
+        close(circbuf_fd);
+        return ;
+    }
+    
+    InitTimer();
+    wp=wp0=0;
+    
+    nframe = HDR_INTERVAL;
+    nframes_total = 0;    // unlimited 
+    nframes_inter_full = 128;
+    nframes_inter_masked = 0;
+    time_slow = (int)(100./strm_data_par.fps);
+    fprintf(stderr,"fps =%f time_slow %d\n",strm_data_par.fps,time_slow);
+    acq_data = ((nframes_total)<<16 ) 
+              | (((nframes_inter_full   > 255)? 
+                255:
+                ((nframes_inter_full   < 0)?0:nframes_inter_full  )) << 8) 
+              | ((nframes_inter_masked > 255)? 
+                255:
+                ((nframes_inter_masked < 0)?0:nframes_inter_masked));
+
+    if(setup_tbl_FPGA( nframes_total, nframes_inter_full,
+                                      nframes_inter_masked, time_slow)<0)
+        return;
+    
+    if(make_OggTheoraHdrs(headers_filename)<0) {
+        fprintf(stderr,"Error prepare headers while parsing %s\n",headers_filename);
+        free(b_headers);
+        return;
+    }
+    frame_no = 0;
+
+    while (true) {
+        // start acquisition
+        fprintf(stderr,"start acquisition\n");
+        if ((devfd = open(controlfn, O_RDONLY)) <0) {
+            fprintf(stderr,"error opening file %s for reading - error = %d (%s)\n",
+                    controlfn,errno,strerror(errno));
+            return ;
+        }
+        // start compression
+        fprintf(stderr,"start compressoin\n");
+        ioctl(devfd, _IO(CMOSCAM_IOCTYPE, IO_CCAM_JPEG_GET_N ), acq_data);
+
+        //wait for encoding to be done (or aborted?)
+        fprintf(stderr,"wait for encoding\n");
+        while ((i=ioctl(devfd, _IO(CMOSCAM_IOCTYPE, IO_CCAM_MONITOR_SEQ ), 0)) > CAMSEQ_JPEG) {
+            if(strm_data->status == STOP_STREAM ) {
+                break;   // receive command STOP from web interface
+            }
+            // has to break here if http connection is closed
+            
+            // data ready ?    
+            if(wp == 0) {
+                while(frame_no <0)
+                    frame_no = ioctl(devfd, _CCCMD( CCAM_RPARS , P_JPEG_WP), 0)-1;
+                usec_sleep(mTimeinterval>>1);
+                sched_yield();
+                wp=1;
+            }
+
+            // dark_loop
+            fprintf(stderr,"dark loop\n");
+            do {
+                // what does this do??? 
+                last_page_flags= (ccam_dma_index[frame_no+1]==0xffffffff)?4:0;
+                
+                if (last_page_flags == 4) {
+                   usec_sleep(mTimeinterval);
+                   sched_yield();
+                }
+            } while(last_page_flags == 4);
+            fprintf(stderr,"dark loop done\n");
+            //frame_no = ioctl(devfd, _CCCMD( CCAM_RPARS , P_JPEG_WP), 0)-1;
+            // soft correction FPS    
+
+            frame_length=(ccam_dma_index[frame_no] & 0xfffffff)-frame_start;
+  
+            //index of next frame in dma
+            next_frame_start=((ccam_dma_index[frame_no] & 0xfffffff)+63) & (~0x1f);
+
+            frame_type=(ccam_dma_index[frame_no]>>28) & 3;
+
+            // figure out what this does?
+            wp0 = ioctl(devfd, _CCCMD( CCAM_RPARS , P_JPEG_WP), 0)-1;
+            if(wp0 < 0) {
+                fprintf (stderr,"frame length %d \tframe_no %d = %d \n",
+                                                     frame_length,frame_no,wp0);
+                frame_no=wp0;
+                wp = 0;
+                continue;
+            }
+
+            time_frame+= mTimeinterval; // time start for next frame INTER/INTRA
+
+            //pointer to next theora frame in camera dma
+            dp=&ccam_dma[frame_start];
+
+            //why this check for 1000000?
+            if((unsigned)frame_length <1000000) {
+                fprintf(stderr,"ogg_frame_page\n");
+                header_length= ogg_frame_page (&header,       // [1]
+                                       last_page_flags,       // [2]
+                                       page_size,             // [3]
+                                       granule,
+                                       stream_serial,
+                                       page++,
+                                       packets[3+frame_type], // [4]
+                                       &frame_length,         // [5]
+                                       &dp                    // [6]
+                                      );
+                
+                /*
+                 [1] pointer to the header data
+                     (returns - header length in bytes)
+                 [2] +1 - continuation, +4 - last (+2 - first)
+                     "last" will be masked out if needed
+                 [3]  maximal; page size to use
+                 [4]  not used if (flags & 1). 
+                      frame_header.len is measured in bits, not bytes!
+                 [5]  frame data length
+                 [6]  pointer to array with frame data(bytes)
+                */
+                
+                //FIXME now actually print the ogg page here.
+                fprintf(stderr,"FIXME, now print ogg page, header_length %d = frame_length %d \n",
+                                                     header_length,frame_length);
+                
+            }
+            frame_start=next_frame_start;
+            frame_no++;
+            if(frame_no > wp0)
+                wp = 0;
+
+            nframe++;
+            //???
+            //xmemchk();
+        }
+        if(strm_data->status == STOP_STREAM ) {
+        // stop sencor
+            // system("hello -z 0");
+            fprintf (stderr,"RTP Streamer stopped \n");
+            break;   // receive command STOP from web interface
+            //ioctl(devfd, _IO(CMOSCAM_IOCTYPE, IO_CCAM_JPEG ), JPEG_CMD_STOP);
+        } // if STOP_STREAM         
+    } // while main    
+//=========================== END MAIN LOOP ============================ 
+}
+
+
+int main(int argc, char *argv[]) 
+{
+    int         devfd,c,flag,use_web;
+
+    flag = 0;
+    use_web = false;
+    strcpy(strm_data_par.address,"239.0.0.1");
+    strm_data_par.port = 20000;
+    strm_data_par.fps  = 25.;
+    strm_data_par.status   = START_STREAM;
+    //strm_data_par.regim    = JPEG_ACCESS_DRV; 
+    //strm_data_par.scanning = STOP_SCANNING;
+    strcpy(strm_data_par.name,"Elphel Camera #1");
+    strcpy(strm_data_par.telephone,"1-800-RTP-HOT-PHONE");
+    strcpy(strm_data_par.toolname,"Elphel Theora Streamer");
+    strcpy(strm_data_par.note,"Draft release ofr RTP Theora");
+    strcpy(strm_data_par.location,"This camera located anywhere");
+    strcpy(strm_data_par.email,"camera at elphel.com");
+    strm_data_par.encrypt_key[0]='\0';
+
+    while(true) {
+        c = getopt(argc, argv, "hwa:p:f:k:");
+        if (c == -1)
+            break;
+     
+        switch (c) {
+            case 'h':
+                flag++;    
+                break;
+            case 'w':
+                use_web = true;     
+                break;
+            case 'a':
+                memset(strm_data_par.address,0,21);
+                strncpy(strm_data_par.address,optarg,20);
+                break;
+            case 'k':
+                memset(strm_data_par.encrypt_key,0,41);
+                strncpy(strm_data_par.encrypt_key,optarg,40);
+                strm_data_par.encryption=1;
+                break;
+            case 'p':
+                strm_data_par.port = atol(optarg);    
+                break;
+            case 'f':
+                strm_data_par.fps = atof(optarg);
+                if(strm_data_par.fps < 0. )
+                    strm_data_par.fps=25.;    
+                break;
+            case '?':
+                flag++;
+                break;
+            default:
+                fprintf (stderr,"?? getopt returned character code 0%o ??\n", c);
+        }
+    }
+    if ((optind < argc)|| flag>0) {
+        usage();
+        exit(1);
+    }
+    if(use_web) {
+        unlink(mmapFileName);
+        // map shared memory for manage this with CGI 
+        // where shared memory opening whith query too
+    
+        devfd = open(mmapFileName,O_RDWR|O_CREAT); 
+        if(devfd == -1) {
+            printf("Error opening %s!\n",mmapFileName);
+        }
+        lseek(devfd,sizeof(strm_data_t),SEEK_SET);
+        write(devfd,"",1);
+        strm_data = (strm_data_t *) mmap(0, sizeof(strm_data_t), 
+                                     PROT_READ|PROT_WRITE, MAP_SHARED, devfd, 0);
+        if((int)strm_data == -1) {
+             fprintf(stderr,"Error in mmap %s\r\n",mmapFileName);
+             close(devfd);
+             unlink(mmapFileName);
+             exit(1);
+        }
+    } 
+    else {
+        strm_data = &strm_data_par;  // use data from local buffer   
+        // not used web - start streamer immediate
+        strm_data_par.status = START_STREAM;
+    }       
+    
+    // OK - init data
+
+    // General LOOP waiting command START
+    while(true) {
+         if(strm_data->status == -1)
+            break;
+         if(strm_data->status == STOP_STREAM ) {
+            //sleep some time and test status again
+            usec_sleep(100000);
+            continue;
+         }
+
+        mTimeinterval = (int) TimestampTicks/strm_data->fps; // min interval between frames
+        fprintf(stderr,"Time frame %u for FPS %f, dest address %s:%d \n\n", mTimeinterval, strm_data->fps, 
+        strm_data->address,strm_data->port);
+        memcpy((void *)&strm_data_par,(void *)strm_data,sizeof(strm_data_t));
+         
+        fprintf(stderr,"\n HTTP Streamer for Theora starting...\n");
+        main_loop();
+  } // general while    
+  return 0;
+}

Added: experimental/j/Elphel333/http/config_cgi/.target-makefrag
===================================================================
--- experimental/j/Elphel333/http/config_cgi/.target-makefrag	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/http/config_cgi/.target-makefrag	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1 @@
+AXIS_BUILDTYPE=cris-axis-linux-gnu

Added: experimental/j/Elphel333/http/config_cgi/Makefile
===================================================================
--- experimental/j/Elphel333/http/config_cgi/Makefile	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/http/config_cgi/Makefile	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,49 @@
+AXIS_USABLE_LIBS = UCLIBC GLIBC
+include $(AXIS_TOP_DIR)/tools/build/Rules.axis
+
+INCDIR    = $(prefix)/include
+LIBDIR    = $(prefix)/lib
+
+INSTDIR   = $(prefix)/bin
+INSTMODE  = 0755
+
+INSTOWNER = root
+INSTGROUP = root
+
+CFLAGS   += -Wall -g -I$(INCDIR) -I$(AXIS_KERNEL_DIR)/include
+LDFLAGS  += -L$(LIBDIR) 
+
+ifndef UCLIBC
+# -lm - to use math library
+LDLIBS = -lcrypt -lm
+endif
+
+# miscellaneous OS-dependent stuff
+# linker
+LN= $(CC)
+# file deletion command
+RM= rm -f
+# file rename command
+MV= mv
+# End of configurable options.
+
+PROGS     = http_strm.cgi
+
+APPSOURCES= http_strm.c 
+SRCS= $(APPSOURCES)
+
+APPSOBJ= http_strm.o 
+
+OBJS= $(APPSOBJ)
+
+CFLAGS	+= -Wall
+
+all:	$(PROGS)
+
+http_strm.cgi: $(OBJS)
+	$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
+	strip-cris http_strm.cgi
+
+clean:
+	rm -f $(PROGS) *.o *.bak *~ core 
+

Added: experimental/j/Elphel333/http/config_cgi/http_strm.c
===================================================================
--- experimental/j/Elphel333/http/config_cgi/http_strm.c	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/http/config_cgi/http_strm.c	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,206 @@
+/******************************************************************************
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * ******************************************************************************/
+// CGI interface dispatcher for Theora http stream on  Elphel 333 camera
+// Copyright (c) 2005 Jan Gerber
+// /////////////////////////////////////////////////////////////////////////////
+
+#include <fcntl.h>  /*open*/
+#include <unistd.h> /* close, sleep */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+
+#include <sys/types.h> /* for fstat */
+#include <sys/stat.h> /* for fstat */
+
+#include <sys/mman.h>    /* mmap */
+
+#include <string.h>
+#include <errno.h>
+#include <math.h>
+
+#define QRY_MAXPARAMS 64
+struct key_value {
+  char *key;
+  char *value;
+};
+
+struct key_value gparams[QRY_MAXPARAMS+1];
+
+#define STOP_STREAM     0
+#define START_STREAM    1
+#define STOP_SCANNING   0
+#define START_SCANNING  1
+
+#define JPEG_ACCESS_MMAP 1
+#define JPEG_ACCESS_DRV  2
+
+typedef struct strm_common {
+  char   address[21];     // address or hostname
+  int    port;    // port no
+  double fps;    // soft FPS
+  int    regim;    // mmap/driver access to JPEG data
+  int    scanning;  // mode scanning on/off
+  char   name[21];  // SDES name field for subtitles
+  char   telephone[21];  // phone subtitles
+  char   toolname[21];
+  char   note[61];
+  char   location[41];
+  char   email[21];
+  char   encrypt_key[41];// encryption key
+  int    encryption;  // mode encryption on/off
+  int    status;    // start/top streamer
+} strm_data_t;
+
+
+/////////////////////// prototypes /////////////////////////////////////////
+int parseQuery(struct key_value * params, char * qry);
+char * paramValue(struct key_value * params, char * skey); // returns pointer to parameter value, NULL if not defined
+int unescape (char * s, int l);
+int hexdigit (char c);
+
+///////////////////////////////////////////////////////////////////////////
+
+int hexdigit (char c) {
+  int i;
+  i=c-'0';
+  if ((i>=0) && (i<10)) return i;
+  i=c-'a'+10;
+  if ((i>=10) && (i<16)) return i;
+  i=c-'A'+10;
+  if ((i>=10) && (i<16)) return i;
+  return 0;  // could be -1??
+}
+
+int unescape (char * s, int l) {
+  int i=0;
+  int j=0;
+  while ((i<l) && s[i]) {
+    if ((s[i]=='%') && (i<(l-2)) && s[i+1]){ // behavior from Mozilla
+      s[j++]=(hexdigit(s[i+1])<<4) | hexdigit(s[i+2]);
+      i+=3;
+    } else s[j++]=s[i++];
+  }
+  if (i<l) s[j]=0;
+  return j;
+}
+
+int parseQuery(struct key_value * params, char * qry)
+{
+  char * cp;
+  int l=0;
+  cp=strtok(qry,"=");
+  while ((cp) && (l<QRY_MAXPARAMS)) {
+    params[l].key=cp;
+    cp=strtok(NULL,"&");
+    params[l++].value=cp;
+    if (cp) cp=strtok(NULL,"=");
+  }
+ params[l].key=NULL;
+ return l;
+}
+
+char * paramValue(struct key_value * params, char * skey)
+{ // returns pointer to parameter value, NULL if not defined
+  int i=0;
+  if (skey)
+   while ((i<QRY_MAXPARAMS) && (params[i].key)) {
+    if (strcmp(skey,params[i].key)==0) return   params[i].value;
+
+    i++;
+   }
+  return NULL;
+}
+
+
+////////////////////////////////////////////////////////////////////////
+int main (int argc, char *argv[]) {
+  int devfd,i,code;
+  char * cp;
+  char * vp;
+  /* these are from cgitest.cgi */
+  const char *method;
+  const char *query;
+  const char *uri;
+  char  copyQuery [4096];
+
+  const char mmapFileName[]= "/var/tmp/mmap_strm";
+  strm_data_t    *strm_data;
+
+  method = getenv("REQUEST_METHOD");
+  query  = getenv("QUERY_STRING");
+  uri    = getenv("REQUEST_URI");
+  i= (query)? strlen (query):0;
+     fprintf(stderr,"querry length=%d\n", i);
+
+  if (i>(sizeof(copyQuery)-1)) i= sizeof(copyQuery)-1;
+  if (i>0) strncpy(copyQuery,query, i);
+  copyQuery[i]=0;
+  unescape(copyQuery,sizeof(copyQuery));
+
+  if (method == NULL) {
+    /* Not a CGI! */
+    printf("This program should be run as a CGI from the web server!\n");
+    exit(1);
+  }
+
+  parseQuery(gparams, copyQuery);
+  //open mmap memory
+  devfd = open(mmapFileName,O_RDWR);   //S_IRWXU);
+  if(devfd == -1) {
+    printf("Error create SHM data!\n");
+  }
+  lseek(devfd,sizeof(strm_data_t),SEEK_SET);
+  strm_data = (strm_data_t *)mmap(0, sizeof(strm_data_t), PROT_READ|PROT_WRITE, MAP_SHARED, devfd, 0);
+  if((int)strm_data == -1) {
+    fprintf(stderr,"Error in mmap %s\r\n",mmapFileName);
+    close(devfd);
+    exit(1);
+  }
+  code = STOP_STREAM;
+  if((vp=paramValue(gparams, "c")))  
+    code = strtol(vp,&cp,10);
+  if((strm_data->status == START_STREAM ) && code== START_STREAM) {
+    // streamer already started! Restart it with new parameters
+    strm_data->status = STOP_STREAM;
+    // wait some time
+    usleep(100000);
+   }
+
+   if ((vp=paramValue(gparams, "addr")))  strncpy(strm_data->address,vp,20);
+   if ((vp=paramValue(gparams, "port")))  strm_data->port = strtol (vp,&cp,10);
+   if ((vp=paramValue(gparams, "fps")))   strm_data->fps  = strtod(vp,&cp);
+   if ((vp=paramValue(gparams, "scan")))  strm_data->scanning = strtol (vp,&cp,10);
+   if ((vp=paramValue(gparams, "reg")))   strm_data->regim = strtol (vp,&cp,10);
+
+   if ((vp=paramValue(gparams, "name")))  strncpy(strm_data->name,vp,20);
+   if ((vp=paramValue(gparams, "loc")))   strncpy(strm_data->location,vp,40);
+   if ((vp=paramValue(gparams, "note")))  strncpy(strm_data->note,vp,60);
+   if ((vp=paramValue(gparams, "tool")))  strncpy(strm_data->toolname,vp,20);
+   if ((vp=paramValue(gparams, "phone"))) strncpy(strm_data->telephone,vp,20);
+   if ((vp=paramValue(gparams, "email"))) strncpy(strm_data->email,vp,20);
+   if ((vp=paramValue(gparams, "key")))   strncpy(strm_data->encrypt_key,vp,40);
+   if ((vp=paramValue(gparams, "encr")))  strm_data->encryption = strtol (vp,&cp,10);
+
+   // OK - new parameters passed to mapped memory
+   // start streamer
+
+   strm_data->status = code;
+   close(devfd);
+   return 0;
+}

Added: experimental/j/Elphel333/http/config_cgi/index1.html
===================================================================
--- experimental/j/Elphel333/http/config_cgi/index1.html	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/http/config_cgi/index1.html	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,1215 @@
+<html>
+<head>
+<style>
+<!--
+#window_selection{
+position:absolute;
+left:0;
+top:0;
+width:1px;
+height:1px;
+color:red;
+z-index:100;
+font-size:1px;
+border: 1px #FF0000 solid;}
+
+.inputs    {  background-color: #EEEEEE; text-align: right; font-family: Verdana, Arial, Helvetica, sans-serif}
+.textStyle {  font-family: Verdana, Arial, Helvetica, sans-serif}
+.info      {  background-color: #aaaaaa; text-align: right; font-family: Verdana, Arial, Helvetica, sans-serif; color: #FF0033}
+.nowrap    {  text-align: right; white-space: nowrap;}
+-->
+</style>
+
+<script language="JavaScript">
+var isDOM=document.getElementById?true:false;
+var isOperaIE= document.all?true:false;
+  document.dragging=false;
+  document.dragEn=false;
+  document.previewDecimation=2;
+//  document.previewScale=1/document.previewDecimation;
+  document.maxWidth=1280;
+  document.maxHeight=1024;
+  document.dcm=1;
+  document.flipX=1;
+  document.flipY=0;
+  document.cgi="/admin-bin/ccam.cgi?";
+  document.previewURL="";
+  document.newWinURL="";
+  document.updateURL="";
+  document.startStopClipURL="pics/1pix.jpeg";
+  document.commonParameters="";
+//  document.commonOptions="vxych";
+//  document.defaultOptions="vxyh";
+  document.defaultOptions="vh";
+  document.saveExposure=20;
+  document.firstX=0;
+  document.firstY=0;
+  document.sizeX; // signed
+  document.sizeY; // signed
+  document.discret=1;
+  document.snap=4;
+  document.mapTop=0;
+  document.mapLeft=0;
+  document.mapWidth= document.maxWidth/document.previewDecimation;
+  document.mapHeight=document.maxHeight/document.previewDecimation;
+  document.minTilesX=2;
+  document.minTilesY=2;
+  document.imageGot=0;
+  document.clipFrame=0;
+  document.sensor=49; // MT9M001
+  document.sensorBlack=0;
+  document.sensorWhite=254;
+  document.updateTime=3000; // will sync if not in use longer than...
+  document.timeoutCntr=0;  // watches if there is any pending timeout
+  document.updating=0;
+  document.dummyImg=new Image();
+  document.timeNotSet=1;
+  document.acquireImage=""; // string to evaluate after camera is tested that it is not running streamer
+  document.discret_x=128;
+  document.discret_y=64;
+//////////// for Theora RTP streamer ///////////////////
+  document.Address = "239.0.0.1";
+  document.Port = 20000;
+  document.Sfps = 15;
+  document.cgi_strm ="/admin-bin/cstrm.cgi?";  
+  document.startStopStreamerURL="pics/1pix.jpeg";
+
+//////////////////////////////// STREAMER FUNCTIONS ///////////////////////////////////////////
+function StreamerStartStop(c) {
+
+ document.Sfps=parseFloat(document.getElementById("idRequestedFPS").value);
+ document.startStopStreamerURL=document.cgi_strm+"opt=s&addr="+document.Address
+  				+"&port="+document.Port+"&fps="+document.Sfps
+		                +"&c="+c
+  if(c==1) {
+    document.dummyImg.src=document.startStopStreamerURL;
+   } 
+   else { 
+    document.dummyImg.src=document.startStopStreamerURL;
+   }
+//alert(document.startStopStreamerURL);
+}
+
+function updateAddress() {
+document.Address=document.getElementById("idAddress").value;
+
+//alert('change Address for stream '+document.Address);
+}
+
+function updatePort() {
+var port=parseInt(document.getElementById("idPort").value);
+if (port < 20000) { alert( 'Port must be above 20000 !!! ');
+	document.Port=20000;
+	document.getElementById("idPort").value=20000;
+} else if(port>50000) { alert("Port number to big!");
+	document.Port=20000;
+	document.getElementById("idPort").value=20000;
+}else if (Math.floor(port/2)*2 !=port) { alert("Port number must be EVEN !!! ");
+		document.Port = 20000;
+ 	     document.getElementById("idPort").value=20000;	
+} else document.Port=port;
+
+}
+/////////////////////////////////////// Streamer END /////////////////////////////////////////////////////////////
+
+
+// XML related stuff
+// abort did not work? try different object
+function loadXMLDocDummy(url) {
+    // branch for native XMLHttpRequest object
+    if (window.XMLHttpRequest) {
+        dummyReq = new XMLHttpRequest();
+        dummyReq.onreadystatechange = processDummyReqChange;
+        dummyReq.open("GET", url, true);
+        dummyReq.send(null);
+    // branch for IE/Windows ActiveX version
+    } else if (window.ActiveXObject) {
+        dummyReq = new ActiveXObject("Microsoft.XMLHTTP");
+        if (dummyReq) {
+            dummyReq.onreadystatechange = processDummyReqChange;
+            dummyReq.open("GET", url, true);
+            dummyReq.send();
+        }
+    }
+}
+function processDummyReqChange() {
+    if ((dummyReq.readyState >1 ) && document.timeNotSet) {
+      document.timeNotSet=0;
+      dummyReq.abort();  // abort that reply from 1972
+      updateXML(); // start over again
+    }
+}
+
+
+function loadXMLDoc(url) {
+    // branch for native XMLHttpRequest object
+    if (window.XMLHttpRequest) {
+        req = new XMLHttpRequest();
+        req.onreadystatechange = processReqChange;
+        req.open("GET", url, true);
+        req.send(null);
+    // branch for IE/Windows ActiveX version
+    } else if (window.ActiveXObject) {
+        req = new ActiveXObject("Microsoft.XMLHTTP");
+        if (req) {
+            req.onreadystatechange = processReqChange;
+            req.open("GET", url, true);
+            req.send();
+        }
+    }
+}
+function processReqChange() {
+    // only if req shows "loaded"
+    if (req.readyState == 4) {
+        // only if "OK"
+        if (req.status == 200) {
+            // ...processing statements go here...
+          getFromCamera();
+        } else {
+            alert("There was a problem retrieving the XML data:\n" +
+                req.statusText);
+        }
+    }
+    window.status=req.readyState;
+//   if (req.readyState>1)   alert("req.readyState="+req.readyState);
+}
+
+function acquireIfCan(cmd) {
+    // branch for native XMLHttpRequest object
+    document.acquireImage=cmd;
+//    myAlert("acquireIfCan: "+cmd);
+    
+    url=document.loadXMLStateURL;
+    if (window.XMLHttpRequest) {
+        camState = new XMLHttpRequest();
+        camState.onreadystatechange = processStateChange;
+        camState.open("GET", url, true);
+        camState.send(null);
+    // branch for IE/Windows ActiveX version
+    } else if (window.ActiveXObject) {
+        camState = new ActiveXObject("Microsoft.XMLHTTP");
+        if (camState) {
+            camState.onreadystatechange = processStateChange;
+            camState.open("GET", url, true);
+            camState.send();
+        }
+    }
+}
+function processStateChange() {
+    // only if req shows "loaded"
+    if (camState.readyState == 4) {
+        // only if "OK"
+        if (camState.status == 200) {
+            // ...processing statements go here...
+           if (parseInt(camState.responseXML.getElementsByTagName('SENSOR_STATE' )[0].firstChild.nodeValue)>7)  {
+              alert("Can not acquire preview image as streamer is possibly running.\n"+
+                      "You may want to try to stop it or reset the camera");
+// and just do nothing...                      
+           } else {
+// here - actually acquire requested image
+             eval(document.acquireImage);
+           }           
+
+
+        } else {
+            alert("There was a problem retrieving the XML data:\n" +
+                camState.statusText);
+        }
+    }
+}
+
+function updateXML() {
+ document.updating++;
+ updateLinks(); // move it later outside?
+ if (document.timeNotSet) loadXMLDocDummy(document.loadXMLDocURL);
+ else                     loadXMLDoc(document.loadXMLDocURL);
+ 
+// alert(document.updating);
+}
+function myAlert(s) {
+  var sl=60;
+  var i=0;
+
+  while (i< s.length) {
+   if ((s.length-i)<sl) sl=s.length-i;
+   s=s.substr(0,i).concat("\n",s.substr(i, s.length-i));
+   i+=sl+1;
+  }
+ alert (s);  
+}
+function watchDog(t) {
+  document.timeoutCntr++;
+ window.status=document.timeoutCntr;
+//  setTimeout('document.timeoutCntr--;',t);
+  setTimeout('document.timeoutCntr--;window.status=document.timeoutCntr',t);
+}
+
+
+
+
+
+
+function updateFPS() {
+}
+
+function g2n() { // setst numeric window dimentions accrording to dragging
+// update values in the text fields
+ document.getElementById("idHeight").value= Math.round(Math.abs(document.sizeY)*document.previewDecimation);
+ document.getElementById("idWidth").value=  Math.round(Math.abs(document.sizeX)*document.previewDecimation);
+/* document.getElementById("idBottom").value= document.maxHeight-
+       (Math.round(Math.min(document.firstY, document.firstY + document.sizeY + document.discret)*document.previewDecimation)+document.getElementById("idHeight").value);
+*/       
+/*
+ document.getElementById("idBottom").value= document.maxHeight-
+       (Math.round(Math.max(document.firstY, document.firstY + document.sizeY + document.discret)*document.previewDecimation)+document.getElementById("idHeight").value);
+*/       
+ document.getElementById("idBottom").value= Math.round((document.mapHeight-Math.max(document.firstY, document.firstY + document.sizeY + document.discret))*document.previewDecimation);
+ document.getElementById("idLeft").value=
+       Math.round(Math.min(document.firstX, document.firstX + document.sizeX + document.discret)*document.previewDecimation);
+ updateNumWindow();
+}
+
+function commonDragging(mouseX,mouseY){ 
+ if (document.dragging) {
+   var dsc=16*document.dcm/document.previewDecimation;
+
+   var y=mouseY - document.mapTop;
+   var x=mouseX - document.mapLeft;
+// Snap to borders
+   if (x<document.snap) x=0;  else if (x>=document.mapWidth-document.snap) x=document.mapWidth-1;
+   if (y<document.snap) y=0;  else if (y>=document.mapHeight-document.snap) y=document.mapHeight-1;
+
+   var h=Math.abs(y-document.firstY)+1;
+   var w=Math.abs(x-document.firstX)+1;
+   h=dsc*Math.floor(h/dsc); if (h<dsc*document.minTilesY) h=dsc*document.minTilesY;
+   w=dsc*Math.floor(w/dsc); if (w<dsc*document.minTilesX) w=dsc*document.minTilesX;
+   if (y<document.firstY)  h=-h;
+   if (x<document.firstX)  w=-w;
+  
+   if ((h!=document.sizeY) || (w!=document.sizeY)) {
+     document.sizeY=h;
+     document.sizeX=w;
+
+   g2n();
+   } 
+ }
+}
+
+function  commonMouseDown (mouseX,mouseY) {
+   document.discret=2*document.dcm/document.previewDecimation; if (document.discret<1) document.discret=1;
+   var y=mouseY - parseInt(document.getElementById("mapImage").style.top);
+   var x=mouseX - parseInt(document.getElementById("mapImage").style.left);
+   document.sizeY=16*document.minTilesY*document.dcm/document.previewDecimation;
+   document.sizeX=16*document.minTilesX*document.dcm/document.previewDecimation;
+// Snap to borders
+   if (x<document.snap) x=0;  else if (x>=document.mapWidth-document.snap) x=document.mapWidth-document.discret;
+   if (y<document.snap) y=0;  else if (y>=document.mapHeight-document.snap) y=document.mapHeight-document.discret;
+
+   document.firstY=document.discret*Math.round(y/document.discret); 
+   document.firstX=document.discret*Math.round(x/document.discret);
+   if ((document.firstY + document.sizeY)>document.mapHeight) document.sizeY =- document.sizeY;
+   if ((document.firstX + document.sizeX)>document.mapWidth)  document.sizeX =- document.sizeX;
+   g2n();
+
+   document.dragging=true;
+
+}
+
+function  commonMouseUp   () {
+ endDragging();
+}
+
+
+
+
+
+function initDragging()
+{
+  if (!document.dragEn) {
+    if(isDOM) {
+	 if (!isOperaIE) {
+       document.getElementById("mapImage").addEventListener("mousemove", dragging_Mozilla, true);
+       document.getElementById("mapImage").addEventListener("mousedown", mouseDown_Mozilla, true);
+       document.getElementById("mapImage").addEventListener("mouseup",   mouseUp_Mozilla, true);
+     } else {
+       document.getElementById("mapImage").onmousemove= dragging_Opera;
+       document.getElementById("mapImage").onmousedown= mouseDown_Opera;
+       document.getElementById("mapImage").onmouseup=   mouseUp_Opera ;
+	 }
+    }
+    else alert ("incompartible browser");
+    document.getElementById("window_selection").style.borderColor= "#00ff00";
+    document.dragEn=true;
+  }
+
+}
+function endDragging()
+{
+ document.dragging=false;
+  if (document.dragEn) {
+    if(isDOM) {
+	 if (!isOperaIE) {
+      document.getElementById("mapImage").removeEventListener("mousemove", dragging_Mozilla, true);
+      document.getElementById("mapImage").removeEventListener("mousedown", mouseDown_Mozilla, true);
+      document.getElementById("mapImage").removeEventListener("mouseup",   mouseUp_Mozilla, true);
+     } else {
+       document.getElementById("mapImage").onmousemove= null;
+       document.getElementById("mapImage").onmousedown= null;
+       document.getElementById("mapImage").onmouseup=   null;
+	 }
+    }
+
+    else alert ("incompartible browser");
+    document.dragEn=false;
+    document.getElementById("window_selection").style.borderColor= "#ff0000";
+  }
+}
+
+function updateColor(){
+ document.commonOptions=document.defaultOptions;
+ if (document.getElementById("idColor").checked)document.commonOptions+="c";
+ if (document.flipX) document.commonOptions+="x";
+ if (document.flipY) document.commonOptions+="y";
+// alert ("updateColor: document.commonOptions="+document.commonOptions);
+ updateLinks();
+}
+
+function updateGamma(){
+var g;
+ g=parseFloat(document.getElementById("idGamma").value);
+ if (!((g>=0.13)&&(g<=10))) document.getElementById("idGamma").value=0.47;
+  updateLinks();
+}
+
+// document.getElementById("idLevelBlack").value=2;
+// document.getElementById("idLevelWhite").value=254;
+function updateLevels(){
+  var vb,vw;
+  vb=parseInt(document.getElementById("idLevelBlack").value);
+  if (!((vb>=0)&&(vb<=254))) {
+    vb=0;
+    document.getElementById("idLevelBlack").value=0;
+  }  
+  vw=parseInt(document.getElementById("idLevelWhite").value);
+  if (!((vw>=vb)&&(vw<=255))) document.getElementById("idLevelWhite").value=255;
+ 
+}
+
+
+
+function updateGains(){
+var g;
+ g=parseInt(document.getElementById("idGainY").value); if (!((g>=0)&&(g<=63))) document.getElementById("idGainY").value=20;
+ g=parseInt(document.getElementById("idGainR").value); if (!((g>=0)&&(g<=63))) document.getElementById("idGainR").value=20;
+ g=parseInt(document.getElementById("idGainG").value); if (!((g>=0)&&(g<=63))) document.getElementById("idGainG").value=20;
+ g=parseInt(document.getElementById("idGainB").value); if (!((g>=0)&&(g<=63))) document.getElementById("idGainB").value=20;
+  updateLinks();
+}
+function updateExposure(){ //now it is measured in 100uS
+//  var e=parseInt(document.getElementById("idExposure").value); if (!((e>0)&&(e<10000))) document.getElementById("idExposure").value=20;
+  var e=parseFloat(document.getElementById("idExposure").value); if (!((e>0)&&(e<10000))) e=20;
+    e=Math.round (10*e)/10;document.getElementById("idExposure").value=e;
+
+//  document.saveExposure=parseInt(document.getElementById("idExposure").value);
+  document.saveExposure=parseFloat(document.getElementById("idExposure").value);
+  document.getElementById("idFrameTime").checked=false;
+  updateLinks();
+}
+function updateFullFrameExposure(){
+  document.getElementById("idExposure").value=(document.getElementById("idFrameTime").checked)?"":document.saveExposure;
+  updateLinks();
+}
+function updateQuality(){
+  var v=v=parseInt(document.getElementById("idQuality").value);
+  if (!((v>0)&&(v<=100))) document.getElementById("idQuality").value=50;
+  updateLinks();
+}
+function updateSaturation(m){ // m=0 - set both (from blue), m=1 - red only
+  var v;
+   if (m>0) {
+     v=parseFloat(document.getElementById("idSaturationRed").value);
+     if (!((v>=0)&&(v<=5))) v=1.0;
+     document.getElementById("idSaturationRed").value=v;
+   } else {
+     v=parseFloat(document.getElementById("idSaturationBlue").value);
+     if (!((v>=0)&&(v<=5))) v=1.0;
+     document.getElementById("idSaturationBlue").value=v;
+     document.getElementById("idSaturationRed").value=v;
+   }     
+  updateLinks();
+}
+function updateVideoSize(){
+      v=parseInt(document.getElementById("idTimeScale").value); if (!((v>0)&&(v<1000))) document.getElementById("idTimeScale").value=10;
+      v=parseInt(document.getElementById("idTheoraFrames").value); if (!((v>0)&&(v<65536))) document.getElementById("idTheoraFrames").value=40;
+      v=parseInt(document.getElementById("idTheoraInter").value); if (!((v>=0)&&(v<256))) document.getElementById("idTheoraInter").value=255;
+  updateLinks();
+}
+function showControls(){
+ var w;
+    w=window.open('vcontrols.html',
+                  'Controls'+escape(document.URL),
+                  'resizable=no,scrollbars=no,status=no,alwaysRaised=yes,height=335,width=100' );
+   w.focus();
+}
+function showClipFrame(){
+//    var w=window.open('clip_frame.html',
+//                  'Frame'+escape(document.URL),
+//                  'resizable=no,scrollbars=no,status=no,alwaysRaised=yes,'+
+//                  'height='+(100+parseInt(document.getElementById('idHeight').value))+
+//                  'width='+(20+parseInt(document.getElementById('idWidth').value)) );
+//   w.focus();
+  acquireIfCan("var w=window.open('clip_frame.html'," +
+               "'Frame'+escape(document.URL)," +
+               "'resizable=no,scrollbars=no,status=no,alwaysRaised=yes,'+" +
+               "'height='+(100+parseInt(document.getElementById('idHeight').value))+ "+
+               "'width='+(20+parseInt(document.getElementById('idWidth').value)) ); "+
+               "w.focus();" );
+
+}
+
+function updateLinks(){
+   var t=new Date();
+   var g;
+   var e=Math.round (parseFloat(document.getElementById("idExposure").value)*10); // 10 times actual
+   var requestedFPS;
+   updateFPS();
+   requestedFPS=parseFloat(document.getElementById("idRequestedFPS").value);
+   if (!(requestedFPS>0)){
+     requestedFPS=0;
+     document.getElementById("idRequestedFPS").value=" ";
+   }
+   var dcms="&dv="+document.dcm+"&dh="+document.dcm+"&";
+   document.commonParameters ="iq="+parseInt(document.getElementById("idQuality").value)+"&"+
+                              "kga="+parseInt(document.getElementById("idGainY").value)+"&"+
+                              "kgm=6&"+
+                              "gr="+ parseInt(document.getElementById("idGainR").value)+"&"+
+                              "gg="+ parseInt(document.getElementById("idGainG").value)+"&"+
+                              "ggb="+parseInt(document.getElementById("idGainG").value)+"&"+
+                              "gb="+ parseInt(document.getElementById("idGainB").value)+"&"+
+                              "csb="+Math.round(100*parseFloat(document.getElementById("idSaturationBlue").value))+"&"+
+                              "csr="+Math.round(100*parseFloat(document.getElementById("idSaturationRed").value))+"&"+
+                              "bit=8"+"&"+
+                              "gam="+Math.round(100*parseFloat(document.getElementById("idGamma").value))+"&"+
+                              "pxl="+parseInt(document.getElementById("idLevelBlack").value)+"&"+
+                              "pxh="+parseInt(document.getElementById("idLevelWhite").value);
+   if (!document.getElementById("idFrameTime").checked)
+     document.commonParameters+="&e="+e;
+   else document.commonParameters+="&e=-1";
+/*
+   document.previewURL=document.cgi+"opt="+document.commonOptions+
+//         "&dv=2&dh=2&ww=1280&wh=1024&wl=0&wt=0&"+
+
+         "&dv="+document.previewDecimation+"&dh="+document.previewDecimation+"&ww="+document.maxWidth+"&wh="+document.maxHeight+"&wl=0&wt=0&"+
+         document.commonParameters+
+         "&fps="+ requestedFPS+
+         "&_time="+t.getTime();
+*/
+   document.previewURL="/pics/nopreview.gif";
+   
+   
+   document.probeURL=document.cgi+"opt="+document.commonOptions+
+         "&dv=1&dh=1&ww=2100&wh=2100&wl=0&wt=0&iq=1"+"&_time="+t.getTime();
+
+  document.commonParameters+= "&ww="+ parseInt(document.getElementById("idWidth").value)+"&"+
+                              "wh="+ parseInt(document.getElementById("idHeight").value)+"&"+
+                              "wl="+ parseInt(document.getElementById("idLeft").value)+"&"+
+                              "wt="+ parseInt(document.getElementById("idBottom").value);
+//new/new win will be ogg/theora
+   document.newWinURL= document.cgi+"opt=o"+document.commonOptions+dcms+
+                       document.commonParameters+
+                       "&fps="+ requestedFPS+
+                       "&tts="+ parseInt(document.getElementById("idTimeScale").value)+
+                       "&tnf="+ parseInt(document.getElementById("idTheoraFrames").value)+
+                       "&tni="+ parseInt(document.getElementById("idTheoraInter").value)+
+                       "&_time="+t.getTime();
+   document.updateURL= document.cgi+"opt="+document.commonOptions+"u"+dcms+
+                       document.commonParameters+
+                       "&fps="+ requestedFPS+
+                       "&_time="+t.getTime();
+
+  document.startStopClipURL=document.cgi+"opt="+document.commonOptions+"q"+dcms+document.commonParameters+
+                              "&qts="+ parseInt(document.getElementById("idTimeScale").value)+
+                              "&fps="+ requestedFPS+
+                              "&_time="+t.getTime()+"&qcmd=";
+   document.getElementById('idStillPhoto').href=document.newWinURL;
+   document.getElementById('idLastPhoto').href=document.cgi+"opt=o"+"&_time="+t.getTime();
+//   document.getElementById('idFrame').href=document.cgi+"hist="+document.clipFrame+"&_time="+t.getTime();
+   document.getElementById('idInfo').href=document.cgi+"html=2"+"&_time="+t.getTime();
+
+/*   document.getElementById('idClip').href=document.cgi+"opt="+document.commonOptions+"q"+dcms+document.commonParameters+
+                              "&qcmd=4"+
+                              "&qts="+ parseInt(document.getElementById("idTimeScale").value)+
+                              "&fps="+ requestedFPS+
+                              "&_time="+t.getTime();*/
+  document.loadXMLDocURL=document.cgi+"html=10&_time="+t.getTime();
+  document.loadXMLStateURL=document.cgi+"html=12&_time="+t.getTime();
+  document.rescueURL=document.cgi+"opt=*q&qcmd=2&_time="+t.getTime(); // unfreeze
+  document.setTimeURL=document.cgi+"_time="+t.getTime(); // unfreeze
+}
+function updateClipFrame(v){
+  if ((v<9999) && (v>-9999)) document.clipFrame=v;
+  document.getElementById("idClipFrame").value=document.clipFrame;
+  updateLinks();
+}
+function changeClipFrame(m) { // m=-2 - first, m=-1 - prev, +1 - next, +2 - last
+  if      (m==-2) document.clipFrame= 1; //first
+  else if (m==-1) document.clipFrame-=1; //previous
+  else if (m== 1) document.clipFrame+=1; //next
+  else if (m== 2) document.clipFrame=0; //last
+  updateClipFrame(document.clipFrame);
+}
+function clipStartStop(c) {
+  updateLinks();
+  document.dummyImg.src=document.startStopClipURL+c;
+}
+function updateParameters() {
+  updateLinks();
+  document.dummyImg.src=document.updateURL;
+}
+function cameraReset() {
+  updateLinks();
+  document.dummyImg.src=document.rescueURL;
+}
+function setTimeIf1972(){
+  updateLinks();
+  document.dummyImg
+  document.dummyImg.onload=updateXML;
+  document.dummyImg.src=document.setTimeURL;
+//  alert(document.dummyImg.src);
+}
+function getFromCamera(){
+   document.imageGot=1;
+   document.maxWidth=                        parseInt(req.responseXML.getElementsByTagName('P_SENSOR_WIDTH' )[0].firstChild.nodeValue);
+   document.maxHeight=                       parseInt(req.responseXML.getElementsByTagName('P_SENSOR_HEIGHT')[0].firstChild.nodeValue);
+// don't read decimation - it will likely be from the perview
+// document.dcm=                             parseInt(req.responseXML.getElementsByTagName('P_DCM_HOR'      )[0].firstChild.nodeValue);
+   
+   document.getElementById("idDCM8").checked=(document.dcm>=8);
+   document.getElementById("idDCM4").checked=((document.dcm>=4) && (document.dcm<8));
+   document.getElementById("idDCM2").checked=((document.dcm>=2) && (document.dcm<4));
+   document.getElementById("idDCM1").checked=                      (document.dcm<2);
+   document.getElementById("idGainY").value= parseInt(req.responseXML.getElementsByTagName('P_SPEC_KAC_GGA' )[0].firstChild.nodeValue);
+   document.getElementById("idGainR").value= parseInt(req.responseXML.getElementsByTagName('P_GAINR'        )[0].firstChild.nodeValue);
+   document.getElementById("idGainG").value= parseInt(req.responseXML.getElementsByTagName('P_GAING'        )[0].firstChild.nodeValue);
+   document.getElementById("idGainB").value= parseInt(req.responseXML.getElementsByTagName('P_GAINB'        )[0].firstChild.nodeValue);
+
+   document.getElementById("idWidth").value= parseInt(req.responseXML.getElementsByTagName('P_WOI_WIDTH'    )[0].firstChild.nodeValue);
+   document.getElementById("idHeight").value=parseInt(req.responseXML.getElementsByTagName('P_WOI_HEIGHT'   )[0].firstChild.nodeValue);
+   document.getElementById("idLeft").value=  parseInt(req.responseXML.getElementsByTagName('P_WOI_LEFT'     )[0].firstChild.nodeValue);
+   document.getElementById("idBottom").value=   parseInt(req.responseXML.getElementsByTagName('P_WOI_TOP'      )[0].firstChild.nodeValue);
+   
+   document.flipX= (parseInt(req.responseXML.getElementsByTagName('P_FLIPH')[0].firstChild.nodeValue)>0)?1:0;
+   document.flipY= (parseInt(req.responseXML.getElementsByTagName('P_FLIPV')[0].firstChild.nodeValue)>0)?1:0;
+   document.getElementById("idColor").checked= (parseInt(req.responseXML.getElementsByTagName('P_COLOR')[0].firstChild.nodeValue)>0)?"true":"false";
+   document.getElementById("idGamma").value= 0.01*parseInt(req.responseXML.getElementsByTagName('P_GAMMA'        )[0].firstChild.nodeValue);
+   document.getElementById("idSaturationBlue").value= 0.01*parseInt(req.responseXML.getElementsByTagName('P_COLOR_SATURATION_BLUE')[0].firstChild.nodeValue);
+   document.getElementById("idSaturationRed").value= 0.01*parseInt(req.responseXML.getElementsByTagName('P_COLOR_SATURATION_RED' )[0].firstChild.nodeValue);
+
+   document.getElementById("idLevelBlack").value=parseInt(req.responseXML.getElementsByTagName('P_PIXEL_LOW' )[0].firstChild.nodeValue);
+   document.getElementById("idLevelWhite").value=parseInt(req.responseXML.getElementsByTagName('P_PIXEL_HIGH')[0].firstChild.nodeValue);
+
+   
+   document.getElementById("idQuality").value= parseInt(req.responseXML.getElementsByTagName('P_QUALITY'      )[0].firstChild.nodeValue);
+   document.getElementById("idExposure").value= 0.1*parseInt(req.responseXML.getElementsByTagName('P_EXPOS'   )[0].firstChild.nodeValue);
+   document.previewDecimation=(document.maxWidth>1600)?4:2;
+
+   document.getElementById('mapImage').style.width=document.maxWidth/document.previewDecimation;
+   document.getElementById('mapImage').style.height=document.maxHeight/document.previewDecimation;
+   document.getElementById('idControls').style.top=document.maxHeight/document.previewDecimation+8;
+   if (document.previewDecimation==2)    document.getElementById('idControls').style.width=document.maxWidth/document.previewDecimation;
+   document.mapWidth= document.maxWidth/document.previewDecimation;
+   document.mapHeight=document.maxHeight/document.previewDecimation;
+//   fullWindow();
+// read defaults if sensor was never programmed 
+   document.sensor=parseInt(req.responseXML.getElementsByTagName('P_SENSOR' )[0].firstChild.nodeValue);
+   if ((!(parseInt(req.responseXML.getElementsByTagName('SENSOR_STATE' )[0].firstChild.nodeValue)>0)) ||
+       (!(parseInt(req.responseXML.getElementsByTagName('P_QUALITY' )[0].firstChild.nodeValue)>0))) {
+         setDefaults();
+   }
+//    else updateLinks();
+   updateColor();
+   updateNumWindow();
+   if (parseInt(req.responseXML.getElementsByTagName('SENSOR_STATE' )[0].firstChild.nodeValue)<8) {
+     document.getElementById("mapImage").style.backgroundImage="url("+document.previewURL+")";
+   } else alert("Can not acquire preview image as streamer is possibly running.\n"+
+              "You may want to try to stop it or reset the camera");
+   if ((document.sensor >=49) && (document.sensor <=51))  document.getElementById("idGainY").style.display="none";
+}
+function setDefaults() {
+// common defaults:
+   document.flipX=1;
+   document.flipY=0;
+   document.getElementById("idColor").checked= true;
+   document.getElementById("idGamma").value= 0.47;
+   document.getElementById("idSaturationBlue").value=2.0;
+   document.getElementById("idSaturationRed").value= 2.0;
+
+   document.getElementById("idQuality").value= 46;
+   document.getElementById("idExposure").value= 20.0;
+// default windows:
+  switch (document.sensor) {
+  case 49: MT9M001_dflt(); break;
+  case 50: MT9D001_dflt(); break;
+  case 51: MT9T001_dflt(); break;
+  default: other_dflt();
+  updateColor();
+//  updateLinks();
+  }
+  
+}
+
+function other_dflt() { // MT9M001_dflt()
+ document.getElementById("idGainY").value=63;
+ document.getElementById("idGainR").value=22;
+ document.getElementById("idGainG").value=16;
+ document.getElementById("idGainB").value=17;
+ document.getElementById("idLevelBlack").value=2;
+ document.getElementById("idLevelWhite").value=254;
+
+}
+function MT9M001_dflt() {
+ document.getElementById("idGainY").value=63;
+ document.getElementById("idGainR").value=22;
+ document.getElementById("idGainG").value=16;
+ document.getElementById("idGainB").value=17;
+ document.getElementById("idLevelBlack").value=2;
+ document.getElementById("idLevelWhite").value=254;
+}
+function MT9D001_dflt() {
+ document.getElementById("idGainY").value=63;
+ document.getElementById("idGainR").value=17; //42
+ document.getElementById("idGainG").value=11; //25
+ document.getElementById("idGainB").value=13; //27
+ document.getElementById("idLevelBlack").value=2;
+ document.getElementById("idLevelWhite").value=254;
+}  
+function MT9T001_dflt() {
+ document.getElementById("idGainY").value=63;
+ document.getElementById("idGainR").value=16;
+ document.getElementById("idGainG").value=11;
+ document.getElementById("idGainB").value=12;
+ document.getElementById("idLevelBlack").value=10;
+ document.getElementById("idLevelWhite").value=254;
+}  
+
+function updateNumWindow() { // validate window sizes, show window
+  if      (document.getElementById("idDCM1").checked) document.dcm=1;
+  else if (document.getElementById("idDCM2").checked) document.dcm=2;
+  else if (document.getElementById("idDCM4").checked) document.dcm=4;
+  else if (document.getElementById("idDCM8").checked) document.dcm=8;
+
+//alert('document.dcm='+document.dcm);
+  var w=parseInt(document.getElementById("idWidth").value);
+  var h=parseInt(document.getElementById("idHeight").value);
+  var l=parseInt(document.getElementById("idLeft").value);
+  var b=parseInt(document.getElementById("idBottom").value);
+//alert("w="+w+"\nh="+h+"\nl="+l+"\nt="+t);
+// l >=0, l<(maxWidth-16*document.dcm)
+/*
+  if (l<0) l=0;
+  if (l>=(document.maxWidth-32*document.dcm)) l=document.maxWidth-32*document.dcm;
+  l= 2*document.dcm*Math.floor(l/2/document.dcm);
+  if((l+w)>document.maxWidth) w= document.maxWidth-l;
+  w=16*document.dcm*Math.floor(w/16/document.dcm);
+  if (w<32*document.dcm) w=32*document.dcm;
+  if (t<0) t=0;
+  if (t>=(document.maxHeight-32*document.dcm)) t=document.maxHeight-32*document.dcm;
+  t= 2*document.dcm*Math.floor(t/2/document.dcm);
+  if((t+h)>document.maxHeight) h= document.maxHeight-t;
+  h=16*document.dcm*Math.floor(h/16/document.dcm);
+  if (h<32*document.dcm) h=32*document.dcm;
+*/
+//  document.discret_x=128;
+//  document.discret_y=64;
+  if (l<0) l=0;
+  if (l>=(document.maxWidth- document.discret_x*document.dcm)) l=document.maxWidth- document.discret_x*document.dcm;
+  l= document.dcm*Math.round(l/document.dcm);
+  if((l+w)>document.maxWidth) w= document.maxWidth-l;
+  w=document.discret_x*document.dcm*Math.round(w/document.discret_x/document.dcm);
+  if (w<document.discret_x*document.dcm) w=document.discret_x*document.dcm;
+  if((l+w)>document.maxWidth) l= document.maxWidth-w;
+  if (b<0) b=0;
+  if (b>=(document.maxHeight - document.discret_y*document.dcm)) b=document.maxHeight - document.discret_y*document.dcm;
+  b= document.dcm*Math.round(b/document.dcm);
+  if((b+h)>document.maxHeight) h= document.maxHeight-b;
+  h=document.discret_y*document.dcm*Math.round(h/document.discret_y/document.dcm);
+  if (h<document.discret_y*document.dcm) h=document.discret_y*document.dcm;
+  if((b+h)>document.maxHeight) b= document.maxHeight-h;
+
+
+// update values in the text fields
+  document.getElementById("idWidth").value=w;
+  document.getElementById("idHeight").value=h;
+  document.getElementById("idLeft").value=l;
+  document.getElementById("idBottom").value=b;
+// show graphically (see if needed 1 extra pixel for the border each side)
+  document.getElementById("window_selection").style.width= (w/document.previewDecimation)-2;
+  document.getElementById("window_selection").style.height=(h/document.previewDecimation)-2;
+  document.getElementById("window_selection").style.left=  l/document.previewDecimation;
+//  document.getElementById("window_selection").style.top=   t/document.previewDecimation;
+  document.getElementById("window_selection").style.top=   (document.maxHeight-b-h)/document.previewDecimation;
+//  alert ("w="+w+"\nh="+h+"\nl="+l+"\nb="+b+"\ndocument.previewDecimation="+document.previewDecimation);
+  updateLinks();
+}
+
+function fullWindow() {
+  document.getElementById("idWidth").value=document.maxWidth;
+  document.getElementById("idHeight").value=document.maxHeight;
+  document.getElementById("idLeft").value=0;
+  document.getElementById("idBottom").value=0;
+  updateNumWindow();
+}  
+
+function imgPreview() {
+//  if (document.imageGot==1) {
+    updateLinks();
+    acquireIfCan("document.getElementById('mapImage').style.backgroundImage='url('+document.previewURL+')';");
+
+
+// disable preview
+//    document.getElementById("mapImage").style.backgroundImage="url("+document.previewURL+")";
+//  } else  imgPreview_init();
+}
+
+function imgNewWindow() {
+  updateLinks();
+  var w=parseInt(document.getElementById("idWidth").value)/document.dcm;
+  var h=parseInt(document.getElementById("idHeight").value)/document.dcm;
+//  window.open(document.newWinURL,'image','resizable=yes,scrollbars=yes, width='+(w+40)+',height='+(h+30));
+  var cmd="window.open(document.newWinURL,'image','resizable=yes,scrollbars=yes, width="+(w+40)+",height="+(h+30)+"');"
+  acquireIfCan(cmd);
+
+}
+
+// Mozilla functions
+function mouseDown_Mozilla (e) {
+ if (document.dragging) mouseUp_Mozilla   (e);
+ else commonMouseDown (e.pageX,e.pageY);
+}
+function dragging_Mozilla(e) {commonDragging(e.pageX,e.pageY);}
+function mouseUp_Mozilla   (e) { commonMouseUp   ();}
+// Opera/IE6 functions
+function mouseDown_Opera (e) {
+ if (document.dragging) mouseUp_Mozilla   (e);
+ else commonMouseDown (event.clientX,event.clientY);
+}
+function dragging_Opera(){ commonDragging(event.clientX,event.clientY);}
+function mouseUp_Opera  () {commonMouseUp   ();}
+
+</script>
+<title>Elphel Model 333 Camera with Ogg/Theora</title>
+</head>
+<!--<body  class="textStyle" bgcolor="#CCCCCC" onLoad="setTimeIf1972();updateColor();updateNumWindow();"> -->
+<body  class="textStyle" bgcolor="#CCCCCC" onLoad="updateXML();">
+
+<!--
+<div id="mapImage" style="position:absolute; width:640px; height:512px; z-index:101; left: 0px; top: 0px;  border-style: solid; background-position: top center; background-repeat: no-repeat; border: 1px none #000000">
+-->
+
+<div id="mapImage" style="position:absolute; width:640px; height:512px; z-index:101; left: 0px; top: 0px;  border-style: solid; background-position: top left; background-repeat: repeat; border: 1px none #000000">
+
+
+  <div id="window_selection"></div>
+</div>
+<div id="idControls" style="position:absolute; width:640px; height:200px; z-index:101; left: 0px; top: 520;">
+
+<form method="post" action="">
+    <table border="1" cellspacing="0" cellpadding="0" width="100%">
+      <tr valign="top"> 
+        <td>
+         <table border="1" cellspacing="0" cellpadding="0" width="100%" height="100%">
+         <tr><td>
+          
+          <table border="0" cellspacing="0" cellpadding="0" width="100%">
+            <tr> 
+              <td colspan="2"> 
+                <div align="center"><b>Window</b> </div>
+              </td></tr>
+<!--            <tr><td colspan="2">&nbsp;</td></tr> -->
+              <tr>
+              <td> 
+                <div align="center">
+                  <input type="button" id="idSelectDrag" value="Drag" onClick="initDragging();" >
+                </div>
+              </td>
+              <td> 
+                <div align="center">
+                  <input type="button" id="idSelectFull" value="Full" onClick="fullWindow();" >
+                </div>
+              </td>
+            </tr>
+<!--            <tr><td colspan="2">&nbsp;</td></tr> -->
+
+            <tr> 
+              <td>
+                <div class="nowrap">
+                W<input type="text" id="idWidth" size="4" maxlength="4" value="1280" onChange="updateNumWindow();" class="inputs"></div>
+              </td>
+              <td> 
+                <div class="nowrap">
+                H<input type="text" id="idHeight" size="4" maxlength="4" value="1024" onChange="updateNumWindow();" class="inputs">
+                </div>
+              </td>
+            </tr>
+              <td>
+                <div class="nowrap">
+                L<input type="text" id="idLeft" size="4" maxlength="4" value="0" onChange="updateNumWindow();" class="inputs">
+                </div>
+              </td>
+              <td> 
+                <div class="nowrap">
+                B<input type="text" id="idBottom" size="4" maxlength="4" value="0" onChange="updateNumWindow();" class="inputs">
+                </div>
+                
+              </td>
+            </tr>
+            
+<!--            <tr><td colspan="2">&nbsp;</td></tr> -->
+            <tr><td>
+            </table>
+            </td> </tr>
+            <tr><td>
+             <table border="0"  width= "100%">
+              <tr>
+               <td colspan="4"><div align="center"><b>Decimation</b></div></td>
+              </tr>
+              <tr>
+               <td>none</td><td>1/2</td><td>1/4</td><td>1/8</td>
+              </tr>
+              <tr>
+               <td> <input type="radio" id="idDCM1" name="nDecimation" value="1" onChange="updateNumWindow();" onClick="updateNumWindow();" checked ></td>
+               <td> <input type="radio" id="idDCM2" name="nDecimation" value="2" onChange="updateNumWindow();" onClick="updateNumWindow();"  ></td>
+               <td> <input type="radio" id="idDCM4" name="nDecimation" value="4" onChange="updateNumWindow();" onClick="updateNumWindow();"  ></td>
+               <td> <input type="radio" id="idDCM8" name="nDecimation" value="8" onChange="updateNumWindow();" onClick="updateNumWindow();" c ></td>
+              </tr>
+             </table>
+            </td></tr>
+
+            
+            <tr > 
+              <td>
+               <table><tr>
+                 <td><div style="nowrap"><b>Quality</b></div></td>
+                 <td><div style="nowrap"><input type="text" id="idQuality" size="2" maxlength="2" value="46" onChange="updateQuality();" class="inputs">%</div></td>
+                </tr>
+               </table>
+              </td>
+            </tr>
+
+
+            <tr>
+              <td>
+                <table><tr> 
+                  <td>Rst</td>
+                  <td><input type="radio" id="idReset" name="nReset" value="1" onClick="cameraReset();"></td>
+                  </td>    
+                  <td>
+                  <input type="button" id="idDefault" value="Defaults" onClick="setDefaults();" >
+                </td>
+                </tr></table>
+              </td>
+            </tr>
+          </table>
+      </td>
+        
+
+        
+      <td>
+       <table border="1" cellspacing="0" cellpadding="0" width="100%" height="100%">
+        <tr><td>
+          <table border="0" cellspacing="0" cellpadding="0" width="100%">
+            <tr>
+              <td colspan="2">
+                <div align="center"><b>Exposure</b></div>
+              </td>
+              </tr>
+              <tr>
+              <td>
+                <div align="right">
+                  <input type="text" id="idExposure" size="5" maxlength="5" value="20" onChange="updateExposure();" class="inputs">
+                </div>
+              </td>
+              <td>ms</td>
+            </tr>
+            <tr>
+              <td>
+                <div align="center">1 frame</div>
+              </td>
+              <td>
+                <input type="checkbox" id="idFrameTime" onClick="updateFullFrameExposure()">
+              </td>
+            </tr>
+          </table>
+        </td></tr>
+        <tr><td>  
+          <table border="0" cellspacing="0" cellpadding="0" width="100%">
+            <tr>
+              <td colspan="2">
+                <div align="center"><b>Gains</b>
+<input type="text" id="idGainY" size="3" maxlength="3" value="100" onChange="updateGains();" class="inputs"></div>
+              </td>
+            <tr>
+              <td> 
+                <div align="right">R </div>
+              </td>
+              <td>
+                <input type="text" id="idGainR" size="3" maxlength="3" value="30" onChange="updateGains();" class="inputs">
+              </td>
+            </tr>
+            <tr> 
+              <td> 
+                <div align="right">G </div>
+              </td>
+              <td>
+                <input type="text" id="idGainG" size="3" maxlength="3" value="25" onChange="updateGains();" class="inputs">
+              </td>
+            </tr>
+            <tr> 
+              <td> 
+                <div align="right">B </div>
+              </td>
+              <td>
+                <input type="text" id="idGainB" size="3" maxlength="3" value="30" onChange="updateGains();" class="inputs">
+              </td>
+            </tr>
+            <tr>
+              <td>Color</td>
+              <td >
+                <input type="checkbox" id="idColor" onClick="updateColor()" checked>
+              </td>
+            </tr>
+           </table>
+         </td></tr>
+        </table> 
+      </td>
+
+
+
+      
+        
+      <td>
+       <table border="1" cellspacing="0" cellpadding="0" width="100%" height="100%">
+        <tr><td>
+          <table border="0" cellspacing="0" cellpadding="0" width="100%">
+            
+            <tr>
+              <td colspan="2"><div align="center"><b>Contrast</b></div></td>
+            </tr>
+            <tr>
+              <td>
+                <div align="right">Gamma</div>
+              </td>
+<!--              <td><input type="text" id="idGainY" size="3" maxlength="3" value="30" onChange="updateGains();" class="inputs"></td> --> <!-- KAC1310-->
+              <td><input type="text" id="idGamma" size="4" maxlength="4" value="0.47" onChange="updateGamma();" class="inputs"></td>
+            </tr>
+            
+            <tr>
+              <td>Levels</td><td> </td>
+            </tr>
+            <tr>
+              <td>
+                <div align="right">Black</div>
+              </td>
+              <td><input type="text" id="idLevelBlack" size="4" maxlength="4" value="0" onChange="updateLevels();" class="inputs"></td>
+            </tr>
+            <tr>
+              <td>
+                <div align="right">White</div>
+              </td>
+              <td><input type="text" id="idLevelWhite" size="4" maxlength="4" value="255" onChange="updateLevels();" class="inputs"></td>
+            </tr>
+
+          </table>
+        </td></tr>
+        <tr><td>
+          <table border="0" cellspacing="0" cellpadding="0" width="100%">
+            <tr>
+              <td colspan="2"><div align="center"><b>Saturation</b></div></td>
+            </tr>
+            <tr>
+              <td>
+                <div align="right">B-Y</div>
+              </td>
+              <td><input type="text" id="idSaturationBlue" size="4" maxlength="4" value="2.0" onChange="updateSaturation(0);" class="inputs"></td>
+            </tr>
+            <tr>
+              <td>
+                <div align="right">R-Y</div>
+              </td>
+              <td><input type="text" id="idSaturationRed" size="4" maxlength="4" value="2.0" onChange="updateSaturation(1);" class="inputs"></td>
+            </tr>
+            
+
+            
+          </table>
+        </td></tr>
+       </table>
+      </td>
+
+
+
+        
+        <td>
+          <table border="1" cellspacing="0" cellpadding="0" width="100%" height="100%">
+            <tr>
+              <td><table border="0" cellspacing="0" cellpadding="0" width="100%" >
+            <tr>
+              <td colspan="2" nowrap="y">
+
+                              <b> Theora Clip: <a id="idStillPhoto" href="#" target="_blank">New</a> : </b>
+                              <b><a id="idLastPhoto" href="#" target="_blank">Last</a></b>
+                             <b><a id="idInfo" href="#" target="_blank">?</a></b> : 
+                             <b><a href="index_help.html" target="_blank">HELP</a></b></div>
+
+                      
+              </td>
+            </tr>
+<!--
+            <tr>
+                    <td>
+                      <div align="center">
+                        <input type="button" id="idPreview" value="Preview" onClick="imgPreview();" >
+                      </div>
+                    </td><td>
+                      <div align="center">
+                        <input type="button" id="idGet" value="Separate window" onClick="imgNewWindow();" >
+                      </div>
+                    </td>
+</tr>          </table></td>
+            </tr>
+-->
+            <tr>
+              <td>
+                <table border="0" cellspacing="0" cellpadding="0" width="100%" >
+<!--
+                  <tr>
+                    <td colspan="2">
+                      <div align="center">
+                        <b><a id="idClip" href="#" target="_blank">Video Clip</a></b>&nbsp;&nbsp;
+                        <b><a id="idClip" href="strctl.cgi" target="_blank">Video Streamers</a></b>
+                      </div>
+                    </td>
+                  </tr>
+
+                  <tr>
+                    <td colspan="2">
+                        <input type="button" id="idStart" value="Start" onClick="clipStartStop(1);" >
+                        <input type="button" id="idStop" value="Stop" onClick="clipStartStop(2);" >
+                        <input type="button" id="idAcquire" value="Acquire" onClick="clipStartStop(3);" >
+                    </td>
+                  </tr>
+              <tr>
+              <tr>
+                <td> <div align="left">
+                    <input type="button" id="idUpdate" value="Update" onClick="updateParameters();" >
+                </div></td>
+                <td>
+                    <input type="button" id="idVcontrols" value="Video Controls" onClick="showControls();" >
+                </td>
+              </tr>
+-->
+              <tr>
+                <td> <div align="left">
+                    Frame rate
+                </div></td>
+                <td>
+                   <input type="text" id="idRequestedFPS" size="5" maxlength="5" value=" " onChange="updateVideoSize();" class="inputs">
+                   fps
+                </td>
+              </tr>
+              <tr>
+                <td> <div align="left">
+                   Time Scale
+                </div></td>
+                <td>
+                   <input type="text" id="idTimeScale" size="3" maxlength="3" value="3" onChange="updateVideoSize();" class="inputs">
+                   x
+                </td>
+              </tr>
+              <tr>
+                <td> <div align="left">
+                   Tot. frames
+                </div></td>
+                <td>
+                   <input type="text" id="idTheoraFrames" size="5" maxlength="5" value="100" onChange="updateVideoSize();" class="inputs">
+                </td>
+              </tr>
+              <tr>
+                <td> <div align="left">
+                   INTER/INTRA
+                </div></td>
+                <td>
+                   <input type="text" id="idTheoraInter" size="3" maxlength="3" value="255" onChange="updateVideoSize();" class="inputs">
+                </td>
+              </tr>
+<!--
+              <tr>
+                <td colspan="2">
+                <input type="button" id="idFBack" value="<<" onClick="changeClipFrame(-2);" >
+                <input type="button" id="idBack" value="<" onClick="changeClipFrame(-1);" >
+                  <input type="text" id="idClipFrame" size="4" maxlength="4" value="0" onChange="updateClipFrame(this.value);" class="inputs">
+                <input type="button" id="idFrw" value=">" onClick="changeClipFrame(1);" >
+                <input type="button" id="idFFrw" value=">>" onClick="changeClipFrame(2);" >
+                </td>
+              </tr>
+              <tr><td colspan="2">
+                <input type="button" id="idShowClipFrame" value="Show clip frame" onClick="showClipFrame();" >
+                 <b><a id="idFrame" href="#" target="_blank">Frame</a></b>              
+              </td></tr>
+-->
+                </table>
+</td>
+            </tr>
+
+          </table>
+        </td>
+    </tr>
+<!-- Video streamer -->
+            <tr>
+              <td>
+                <table border="0" cellspacing="0" cellpadding="0" width="100%" >
+                  <tr>
+                    <td colspan="2">
+                      <div align="center"><b>Theora RTP
+                        Streamer</b>
+                        <img src="pics/1pix.jpeg" width="1" height="1" name="n1pix" id="id1pix">
+                      </div>
+                    </td>
+                  </tr>
+                  <tr>
+                    <td>
+                        <input type="button" id="idStartStrm" value="Start streaming" onClick="StreamerStartStop(1);" >
+                    </td>
+                    <td>
+                        <input type="button" id="idStopStrm" value="Stop streaming" onClick="StreamerStartStop(0);" >
+                    </td>
+                 </tr>
+                 <tr>
+                    <td>
+                      <div align="right">Addr/hostname</div>
+                    </td>
+                    <td> 
+                      <input type="text" id="idAddress" size="15" maxlength="15" value="239.0.0.1" onChange="updateAddress();" class="inputs" name="text">
+                    </td>
+                  </tr>
+                  <tr> 
+                    <td>
+                      <div align="right">Port#</div>
+                    </td>
+                    <td> 
+                      <input type="text" id="idPort" size="5" maxlength="5" value="20000" onChange="updatePort();" class="inputs" name="text">
+                    </td>
+		   </tr>
+
+	      </td>
+	     </tr>
+
+          </table>
+        </td>
+    </tr>
+
+  </table>
+</form>
+</div>
+</body>
+</html>

Added: experimental/j/Elphel333/rtp/README
===================================================================
--- experimental/j/Elphel333/rtp/README	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/README	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,49 @@
+This is experemental RTP Theora streamer for Elphel 333. 
+
+
+with ./init_env loaded you should be able to build cgi and daemon module.
+
+to install:
+daemon/TheoraStrm -> /mnt/flash/local/bin
+cgi/cstrm.cgi     -> /mnt/flash/etc/httpd/html/admin-bin
+cgi/index1.html   -> /mnt/flash/etc/httpd/html/
+
+
+And next - login into camera via telnet and set +x for TheoraStrm and cstrm_cgi via chmod
+
+Ok. Via WEB browser open index1.html(I test it on Firefox). Setup parameters of picture(size, quality and etc)
+and press New. You can't save file.
+
+In field Addr/hostname set address PC (unicast or multicast). If you use multicast address - yuo must set routing on interface of PC:
+
+# route add -net 224.0.0.0 netmask 240.0.0.0 eth0
+
+ and can test multicast 
+
+#ping 224.0.0.1
+
+All host with enablet multicast answer to you(include yours cameras).
+
+In telnet session into camera you can start streamer in waiting mode
+
+# TheoraStrm -w &
+
+Ok. Now press button Start - streamer must starting(you can see message on telnet session) and sending RTP packets into selected address and port. Periodicaly he send headers(after 100 frames) for syncing players.
+
+Ok. on PC you can start receiver:
+
+./TheoraRtp -a <address cam or multicast addr> -p <port> | ./mplayer -vo sdl -nocache -fps <n> -
+
+TheoraRtp syncing with stream and dumping OGG file(builded on fly) into stdout, and next (via pipe) send it to player
+
+You can dump this file too.
+./TheoraRtp -a <addr> -p <port> >file.ogg
+
+
+This is implementation of stream Theora as large file, building on receiver on fly. Receiver can attach to 
+stream on any time(syncing now building on headers in stream, after receive headers we can build and decode
+OGG file).
+
+THIS IS NOT RFC implementation. It is only for testing(We not have complete  RFC of Theora RTP )
+
+Andy Latin

Added: experimental/j/Elphel333/rtp/cgi/.target-makefrag
===================================================================
--- experimental/j/Elphel333/rtp/cgi/.target-makefrag	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/cgi/.target-makefrag	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1 @@
+AXIS_BUILDTYPE=cris-axis-linux-gnu

Added: experimental/j/Elphel333/rtp/cgi/Makefile
===================================================================
--- experimental/j/Elphel333/rtp/cgi/Makefile	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/cgi/Makefile	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,49 @@
+AXIS_USABLE_LIBS = UCLIBC GLIBC
+include $(AXIS_TOP_DIR)/tools/build/Rules.axis
+
+INCDIR    = $(prefix)/include
+LIBDIR    = $(prefix)/lib
+
+INSTDIR   = $(prefix)/bin
+INSTMODE  = 0755
+
+INSTOWNER = root
+INSTGROUP = root
+
+CFLAGS   += -Wall -g -I$(INCDIR) -I$(AXIS_KERNEL_DIR)/include
+LDFLAGS  += -L$(LIBDIR) 
+
+ifndef UCLIBC
+# -lm - to use math library
+LDLIBS = -lcrypt -lm
+endif
+
+# miscellaneous OS-dependent stuff
+# linker
+LN= $(CC)
+# file deletion command
+RM= rm -f
+# file rename command
+MV= mv
+# End of configurable options.
+
+PROGS     = cstrm.cgi
+
+APPSOURCES= cstrm.c 
+SRCS= $(APPSOURCES)
+
+APPSOBJ= cstrm.o 
+
+OBJS= $(APPSOBJ)
+
+CFLAGS	+= -Wall
+
+all:	$(PROGS)
+
+cstrm.cgi: $(OBJS)
+	$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
+	strip-cris cstrm.cgi
+
+clean:
+	rm -f $(PROGS) *.o *.bak *~ core 
+

Added: experimental/j/Elphel333/rtp/cgi/cstrm.c
===================================================================
--- experimental/j/Elphel333/rtp/cgi/cstrm.c	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/cgi/cstrm.c	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,215 @@
+/******************************************************************************
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * ******************************************************************************/
+// CGI interface for Streamer on  Elphel JPEG camera 313 input device
+// // Copyright (c) 2004 Andy Latin aka Landy, Dmitry Latin aka ipfreely
+// // All rights reserved.
+// //
+// // http://andy.qnx.org.ru
+// // mail to:
+// // andy at qnx.org.ru
+// // landy at mail333.com
+// /////////////////////////////////////////////////////////////////////////////
+
+#include <fcntl.h>  /*open*/
+#include <unistd.h> /* close, sleep */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+
+#include <sys/types.h> /* for fstat */
+#include <sys/stat.h> /* for fstat */
+
+#include <sys/mman.h>		/* mmap */
+
+#include <string.h>
+#include <errno.h>
+#include <math.h>
+
+#define QRY_MAXPARAMS 64
+struct key_value {
+	char *key;
+	char *value;
+};
+
+struct key_value gparams[QRY_MAXPARAMS+1];
+
+#define STOP_STREAM     0
+#define START_STREAM    1
+#define STOP_SCANNING   0
+#define START_SCANNING  1
+
+#define JPEG_ACCESS_MMAP 1
+#define JPEG_ACCESS_DRV  2
+
+typedef struct strm_common {
+	char 	address[21];   	// address or hostname
+	int	port;		// port no
+	double	fps;		// soft FPS
+	int     regim;		// mmap/driver access to JPEG data
+	int	scanning;	// mode scanning on/off
+	char 	name[21];	// SDES name field for subtitles
+	char	telephone[21];  // phone subtitles
+	char	toolname[21];
+	char	note[61];
+	char	location[41];
+	char	email[21];
+	char    encrypt_key[41];// encryption key
+	int     encryption;	// mode encryption on/off
+	int	status;		// start/top streamer
+} strm_data_t;
+
+
+
+/////////////////////// prototypes /////////////////////////////////////////
+int parseQuery(struct key_value * params, char * qry);
+char * paramValue(struct key_value * params, char * skey); // returns pointer to parameter value, NULL if not defined
+int unescape (char * s, int l);
+int hexdigit (char c);
+
+///////////////////////////////////////////////////////////////////////////
+
+int hexdigit (char c) {
+  int i;
+  i=c-'0';
+  if ((i>=0) && (i<10)) return i;
+  i=c-'a'+10;
+  if ((i>=10) && (i<16)) return i;
+  i=c-'A'+10;
+  if ((i>=10) && (i<16)) return i;
+  return 0;	// could be -1??
+}
+
+int unescape (char * s, int l) {
+  int i=0;
+  int j=0;
+  while ((i<l) && s[i]) {
+    if ((s[i]=='%') && (i<(l-2)) && s[i+1]){ // behavior from Mozilla
+      s[j++]=(hexdigit(s[i+1])<<4) | hexdigit(s[i+2]);
+      i+=3;
+    } else s[j++]=s[i++];
+  }
+  if (i<l) s[j]=0;
+  return j;
+}
+
+int parseQuery(struct key_value * params, char * qry)
+{
+  char * cp;
+  int l=0;
+  cp=strtok(qry,"=");
+  while ((cp) && (l<QRY_MAXPARAMS)) {
+    params[l].key=cp;
+    cp=strtok(NULL,"&");
+    params[l++].value=cp;
+    if (cp) cp=strtok(NULL,"=");
+  }
+ params[l].key=NULL;
+ return l;
+}
+
+char * paramValue(struct key_value * params, char * skey)
+{ // returns pointer to parameter value, NULL if not defined
+  int i=0;
+  if (skey)
+   while ((i<QRY_MAXPARAMS) && (params[i].key)) {
+    if (strcmp(skey,params[i].key)==0) return 	params[i].value;
+
+    i++;
+   }
+  return NULL;
+}
+
+
+////////////////////////////////////////////////////////////////////////
+int main (int argc, char *argv[]) {
+  int devfd,i,code;
+  char * cp;
+  char * vp;
+/* these are from cgitest.cgi */
+  const char *method;
+  const char *query;
+  const char *uri;
+  char  copyQuery [4096];
+
+  const char mmapFileName[]= "/var/tmp/mmap_strm";
+  strm_data_t    *strm_data;
+
+  method = getenv("REQUEST_METHOD");
+  query  = getenv("QUERY_STRING");
+  uri    = getenv("REQUEST_URI");
+  i= (query)? strlen (query):0;
+     fprintf(stderr,"querry length=%d\n", i);
+
+  if (i>(sizeof(copyQuery)-1)) i= sizeof(copyQuery)-1;
+  if (i>0) strncpy(copyQuery,query, i);
+  copyQuery[i]=0;
+  unescape(copyQuery,sizeof(copyQuery));
+
+  if (method == NULL)
+  {
+    /* Not a CGI! */
+    printf("This program should be run as a CGI from the web server!\n");
+    exit(1);
+  }
+
+  parseQuery(gparams, copyQuery);
+ // open mmap memory
+  devfd = open(mmapFileName,O_RDWR);   //S_IRWXU);
+  if(devfd == -1) {
+	printf("Error create SHM data!\n");
+  }
+  lseek(devfd,sizeof(strm_data_t),SEEK_SET);
+  strm_data = (strm_data_t *)mmap(0, sizeof(strm_data_t), PROT_READ|PROT_WRITE, MAP_SHARED, devfd, 0);
+  if((int)strm_data == -1) {
+        fprintf(stderr,"Error in mmap %s\r\n",mmapFileName);
+        close(devfd);
+	exit(1);
+  }
+  code = STOP_STREAM;
+  if((vp=paramValue(gparams, "c")))  code = strtol(vp,&cp,10);
+  if((strm_data->status == START_STREAM ) && code== START_STREAM) {
+    // streamer already started! Restart it with new parameters
+    strm_data->status = STOP_STREAM;
+    // wait some time
+    usleep(100000);
+   }
+
+    if ((vp=paramValue(gparams, "addr")))  strncpy(strm_data->address,vp,20);
+    if ((vp=paramValue(gparams, "port")))  strm_data->port = strtol (vp,&cp,10);
+    if ((vp=paramValue(gparams, "fps")))   strm_data->fps  = strtod(vp,&cp);
+    if ((vp=paramValue(gparams, "scan")))  strm_data->scanning = strtol (vp,&cp,10);
+    if ((vp=paramValue(gparams, "reg")))   strm_data->regim = strtol (vp,&cp,10);
+
+    if ((vp=paramValue(gparams, "name")))  strncpy(strm_data->name,vp,20);
+    if ((vp=paramValue(gparams, "loc")))   strncpy(strm_data->location,vp,40);
+    if ((vp=paramValue(gparams, "note")))  strncpy(strm_data->note,vp,60);
+    if ((vp=paramValue(gparams, "tool")))  strncpy(strm_data->toolname,vp,20);
+    if ((vp=paramValue(gparams, "phone"))) strncpy(strm_data->telephone,vp,20);
+    if ((vp=paramValue(gparams, "email"))) strncpy(strm_data->email,vp,20);
+    if ((vp=paramValue(gparams, "key")))   strncpy(strm_data->encrypt_key,vp,40);
+    if ((vp=paramValue(gparams, "encr")))  strm_data->encryption = strtol (vp,&cp,10);
+
+    // OK - new parameters passed to mapped memory
+    // start streamer
+
+  strm_data->status = code;
+  close(devfd);
+
+ return 0;
+}
+

Added: experimental/j/Elphel333/rtp/cgi/defines.h
===================================================================
--- experimental/j/Elphel333/rtp/cgi/defines.h	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/cgi/defines.h	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,116 @@
+#ifndef __STREAMER_H_DEF_
+#define  __STREAMER_H_DEF_
+
+#include <inttypes.h>
+
+
+#define HAVE_NANOSLEEP 1
+
+#define MAX_SIZE_JPEG    1024*1024   // max size buffer for JPEG picture, may be increase for best quality
+
+#define JPEG_HEADER_SIZE 	623
+#define RTP_PT_JPEG             26    /* The definition is from RFC1890 */
+#define RTP_JPEG_RESTART        0x40
+#define BUF_SIZE		1460  // MTU - 40 bytes	
+#define TimeScale		90000 // RFC
+
+#define TimestampTicks  	1000000
+
+typedef uint64_t Timestamp;
+typedef uint32_t RtpTimestamp;
+
+
+
+#ifndef true
+#define true		1
+#endif
+#ifndef false
+#define false		0
+#endif
+
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+struct jpeghdr {
+        unsigned int tspec:8;   /* type-specific field */
+        unsigned int off:24;    /* fragment byte offset */
+        uint8_t	     type;      /* id of jpeg decoder params */
+        uint8_t	     q;         /* quantization factor (or table id) */
+        uint8_t      width;     /* frame width in 8 pixel blocks */
+        uint8_t      height;    /* frame height in 8 pixel blocks */
+};
+
+struct jpeghdr_rst {
+        uint16_t     dri;
+        unsigned int f:1;
+        unsigned int l:1;
+        unsigned int count:14;
+};
+
+struct jpeghdr_qtable {
+        uint8_t  mbz;
+        uint8_t  precision;
+        uint16_t length;
+	uint8_t  lqt[64];
+	uint8_t  cqt[64];
+};
+
+///////////// for manage streamer with web interface ///////
+#define STOP_STREAM	0
+#define START_STREAM	1
+#define STOP_SCANNING	0
+#define START_SCANNING	1
+
+#define JPEG_ACCESS_MMAP 1
+#define JPEG_ACCESS_DRV	 2
+
+typedef struct strm_common {
+	char 	address[21];   	// address or hostname
+	int	port;		// port no
+	double	fps;		// soft FPS
+	int     regim;		// mmap/driver access to JPEG data
+	int	scanning;	// mode scanning on/off	 
+	char 	name[21];	// SDES name field for subtitles
+	char	telephone[21];  // phone subtitles
+	char	toolname[21];   
+	char	note[61];
+	char	location[41];
+	char	email[21];
+	char    encrypt_key[41];// encryption key
+	int     encryption;	// mode encryption on/off
+	int	status;		// start/top streamer
+} strm_data_t;
+
+
+///////////////// prototypes ///////////////////////////////////////
+
+int 		usec_sleep(int);
+Timestamp 	GetTimestamp(void);
+Timestamp	GetTimerMs(void);
+Timestamp 	GetRelativeTime(void);
+void 		InitTimer(void);
+void 		SeedRandom(void);
+uint32_t 	GetRandomMcastAddress(void); 
+uint16_t 	GetRandomPortBlock(void);
+RtpTimestamp 	TimestampToRtp(Timestamp);
+Timestamp 	TimestampToNtp(Timestamp);
+
+int  getJPEGdata_mmap(int 		/* mmap file descriptor */, 
+		      unsigned long * 	/* mmap memory */,
+		      int 		/* size of mmap memory */,
+		      int 		/* time interval between frames - 1/fps */, 
+		      uint8_t  	*	/* JPEG data without header but with EOI*/,
+		      uint64_t 	* 	/* time stamp current frame */
+		);
+int getFrame( uint8_t *, uint8_t *, uint8_t *, uint8_t *,
+	    uint16_t *, uint16_t *, uint16_t *, uint8_t *);
+
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
+

Added: experimental/j/Elphel333/rtp/cgi/index1.html
===================================================================
--- experimental/j/Elphel333/rtp/cgi/index1.html	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/cgi/index1.html	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,1215 @@
+<html>
+<head>
+<style>
+<!--
+#window_selection{
+position:absolute;
+left:0;
+top:0;
+width:1px;
+height:1px;
+color:red;
+z-index:100;
+font-size:1px;
+border: 1px #FF0000 solid;}
+
+.inputs    {  background-color: #EEEEEE; text-align: right; font-family: Verdana, Arial, Helvetica, sans-serif}
+.textStyle {  font-family: Verdana, Arial, Helvetica, sans-serif}
+.info      {  background-color: #aaaaaa; text-align: right; font-family: Verdana, Arial, Helvetica, sans-serif; color: #FF0033}
+.nowrap    {  text-align: right; white-space: nowrap;}
+-->
+</style>
+
+<script language="JavaScript">
+var isDOM=document.getElementById?true:false;
+var isOperaIE= document.all?true:false;
+  document.dragging=false;
+  document.dragEn=false;
+  document.previewDecimation=2;
+//  document.previewScale=1/document.previewDecimation;
+  document.maxWidth=1280;
+  document.maxHeight=1024;
+  document.dcm=1;
+  document.flipX=1;
+  document.flipY=0;
+  document.cgi="/admin-bin/ccam.cgi?";
+  document.previewURL="";
+  document.newWinURL="";
+  document.updateURL="";
+  document.startStopClipURL="pics/1pix.jpeg";
+  document.commonParameters="";
+//  document.commonOptions="vxych";
+//  document.defaultOptions="vxyh";
+  document.defaultOptions="vh";
+  document.saveExposure=20;
+  document.firstX=0;
+  document.firstY=0;
+  document.sizeX; // signed
+  document.sizeY; // signed
+  document.discret=1;
+  document.snap=4;
+  document.mapTop=0;
+  document.mapLeft=0;
+  document.mapWidth= document.maxWidth/document.previewDecimation;
+  document.mapHeight=document.maxHeight/document.previewDecimation;
+  document.minTilesX=2;
+  document.minTilesY=2;
+  document.imageGot=0;
+  document.clipFrame=0;
+  document.sensor=49; // MT9M001
+  document.sensorBlack=0;
+  document.sensorWhite=254;
+  document.updateTime=3000; // will sync if not in use longer than...
+  document.timeoutCntr=0;  // watches if there is any pending timeout
+  document.updating=0;
+  document.dummyImg=new Image();
+  document.timeNotSet=1;
+  document.acquireImage=""; // string to evaluate after camera is tested that it is not running streamer
+  document.discret_x=128;
+  document.discret_y=64;
+//////////// for Theora RTP streamer ///////////////////
+  document.Address = "239.0.0.1";
+  document.Port = 20000;
+  document.Sfps = 15;
+  document.cgi_strm ="/admin-bin/cstrm.cgi?";  
+  document.startStopStreamerURL="pics/1pix.jpeg";
+
+//////////////////////////////// STREAMER FUNCTIONS ///////////////////////////////////////////
+function StreamerStartStop(c) {
+
+ document.Sfps=parseFloat(document.getElementById("idRequestedFPS").value);
+ document.startStopStreamerURL=document.cgi_strm+"opt=s&addr="+document.Address
+  				+"&port="+document.Port+"&fps="+document.Sfps
+		                +"&c="+c
+  if(c==1) {
+    document.dummyImg.src=document.startStopStreamerURL;
+   } 
+   else { 
+    document.dummyImg.src=document.startStopStreamerURL;
+   }
+//alert(document.startStopStreamerURL);
+}
+
+function updateAddress() {
+document.Address=document.getElementById("idAddress").value;
+
+//alert('change Address for stream '+document.Address);
+}
+
+function updatePort() {
+var port=parseInt(document.getElementById("idPort").value);
+if (port < 20000) { alert( 'Port must be above 20000 !!! ');
+	document.Port=20000;
+	document.getElementById("idPort").value=20000;
+} else if(port>50000) { alert("Port number to big!");
+	document.Port=20000;
+	document.getElementById("idPort").value=20000;
+}else if (Math.floor(port/2)*2 !=port) { alert("Port number must be EVEN !!! ");
+		document.Port = 20000;
+ 	     document.getElementById("idPort").value=20000;	
+} else document.Port=port;
+
+}
+/////////////////////////////////////// Streamer END /////////////////////////////////////////////////////////////
+
+
+// XML related stuff
+// abort did not work? try different object
+function loadXMLDocDummy(url) {
+    // branch for native XMLHttpRequest object
+    if (window.XMLHttpRequest) {
+        dummyReq = new XMLHttpRequest();
+        dummyReq.onreadystatechange = processDummyReqChange;
+        dummyReq.open("GET", url, true);
+        dummyReq.send(null);
+    // branch for IE/Windows ActiveX version
+    } else if (window.ActiveXObject) {
+        dummyReq = new ActiveXObject("Microsoft.XMLHTTP");
+        if (dummyReq) {
+            dummyReq.onreadystatechange = processDummyReqChange;
+            dummyReq.open("GET", url, true);
+            dummyReq.send();
+        }
+    }
+}
+function processDummyReqChange() {
+    if ((dummyReq.readyState >1 ) && document.timeNotSet) {
+      document.timeNotSet=0;
+      dummyReq.abort();  // abort that reply from 1972
+      updateXML(); // start over again
+    }
+}
+
+
+function loadXMLDoc(url) {
+    // branch for native XMLHttpRequest object
+    if (window.XMLHttpRequest) {
+        req = new XMLHttpRequest();
+        req.onreadystatechange = processReqChange;
+        req.open("GET", url, true);
+        req.send(null);
+    // branch for IE/Windows ActiveX version
+    } else if (window.ActiveXObject) {
+        req = new ActiveXObject("Microsoft.XMLHTTP");
+        if (req) {
+            req.onreadystatechange = processReqChange;
+            req.open("GET", url, true);
+            req.send();
+        }
+    }
+}
+function processReqChange() {
+    // only if req shows "loaded"
+    if (req.readyState == 4) {
+        // only if "OK"
+        if (req.status == 200) {
+            // ...processing statements go here...
+          getFromCamera();
+        } else {
+            alert("There was a problem retrieving the XML data:\n" +
+                req.statusText);
+        }
+    }
+    window.status=req.readyState;
+//   if (req.readyState>1)   alert("req.readyState="+req.readyState);
+}
+
+function acquireIfCan(cmd) {
+    // branch for native XMLHttpRequest object
+    document.acquireImage=cmd;
+//    myAlert("acquireIfCan: "+cmd);
+    
+    url=document.loadXMLStateURL;
+    if (window.XMLHttpRequest) {
+        camState = new XMLHttpRequest();
+        camState.onreadystatechange = processStateChange;
+        camState.open("GET", url, true);
+        camState.send(null);
+    // branch for IE/Windows ActiveX version
+    } else if (window.ActiveXObject) {
+        camState = new ActiveXObject("Microsoft.XMLHTTP");
+        if (camState) {
+            camState.onreadystatechange = processStateChange;
+            camState.open("GET", url, true);
+            camState.send();
+        }
+    }
+}
+function processStateChange() {
+    // only if req shows "loaded"
+    if (camState.readyState == 4) {
+        // only if "OK"
+        if (camState.status == 200) {
+            // ...processing statements go here...
+           if (parseInt(camState.responseXML.getElementsByTagName('SENSOR_STATE' )[0].firstChild.nodeValue)>7)  {
+              alert("Can not acquire preview image as streamer is possibly running.\n"+
+                      "You may want to try to stop it or reset the camera");
+// and just do nothing...                      
+           } else {
+// here - actually acquire requested image
+             eval(document.acquireImage);
+           }           
+
+
+        } else {
+            alert("There was a problem retrieving the XML data:\n" +
+                camState.statusText);
+        }
+    }
+}
+
+function updateXML() {
+ document.updating++;
+ updateLinks(); // move it later outside?
+ if (document.timeNotSet) loadXMLDocDummy(document.loadXMLDocURL);
+ else                     loadXMLDoc(document.loadXMLDocURL);
+ 
+// alert(document.updating);
+}
+function myAlert(s) {
+  var sl=60;
+  var i=0;
+
+  while (i< s.length) {
+   if ((s.length-i)<sl) sl=s.length-i;
+   s=s.substr(0,i).concat("\n",s.substr(i, s.length-i));
+   i+=sl+1;
+  }
+ alert (s);  
+}
+function watchDog(t) {
+  document.timeoutCntr++;
+ window.status=document.timeoutCntr;
+//  setTimeout('document.timeoutCntr--;',t);
+  setTimeout('document.timeoutCntr--;window.status=document.timeoutCntr',t);
+}
+
+
+
+
+
+
+function updateFPS() {
+}
+
+function g2n() { // setst numeric window dimentions accrording to dragging
+// update values in the text fields
+ document.getElementById("idHeight").value= Math.round(Math.abs(document.sizeY)*document.previewDecimation);
+ document.getElementById("idWidth").value=  Math.round(Math.abs(document.sizeX)*document.previewDecimation);
+/* document.getElementById("idBottom").value= document.maxHeight-
+       (Math.round(Math.min(document.firstY, document.firstY + document.sizeY + document.discret)*document.previewDecimation)+document.getElementById("idHeight").value);
+*/       
+/*
+ document.getElementById("idBottom").value= document.maxHeight-
+       (Math.round(Math.max(document.firstY, document.firstY + document.sizeY + document.discret)*document.previewDecimation)+document.getElementById("idHeight").value);
+*/       
+ document.getElementById("idBottom").value= Math.round((document.mapHeight-Math.max(document.firstY, document.firstY + document.sizeY + document.discret))*document.previewDecimation);
+ document.getElementById("idLeft").value=
+       Math.round(Math.min(document.firstX, document.firstX + document.sizeX + document.discret)*document.previewDecimation);
+ updateNumWindow();
+}
+
+function commonDragging(mouseX,mouseY){ 
+ if (document.dragging) {
+   var dsc=16*document.dcm/document.previewDecimation;
+
+   var y=mouseY - document.mapTop;
+   var x=mouseX - document.mapLeft;
+// Snap to borders
+   if (x<document.snap) x=0;  else if (x>=document.mapWidth-document.snap) x=document.mapWidth-1;
+   if (y<document.snap) y=0;  else if (y>=document.mapHeight-document.snap) y=document.mapHeight-1;
+
+   var h=Math.abs(y-document.firstY)+1;
+   var w=Math.abs(x-document.firstX)+1;
+   h=dsc*Math.floor(h/dsc); if (h<dsc*document.minTilesY) h=dsc*document.minTilesY;
+   w=dsc*Math.floor(w/dsc); if (w<dsc*document.minTilesX) w=dsc*document.minTilesX;
+   if (y<document.firstY)  h=-h;
+   if (x<document.firstX)  w=-w;
+  
+   if ((h!=document.sizeY) || (w!=document.sizeY)) {
+     document.sizeY=h;
+     document.sizeX=w;
+
+   g2n();
+   } 
+ }
+}
+
+function  commonMouseDown (mouseX,mouseY) {
+   document.discret=2*document.dcm/document.previewDecimation; if (document.discret<1) document.discret=1;
+   var y=mouseY - parseInt(document.getElementById("mapImage").style.top);
+   var x=mouseX - parseInt(document.getElementById("mapImage").style.left);
+   document.sizeY=16*document.minTilesY*document.dcm/document.previewDecimation;
+   document.sizeX=16*document.minTilesX*document.dcm/document.previewDecimation;
+// Snap to borders
+   if (x<document.snap) x=0;  else if (x>=document.mapWidth-document.snap) x=document.mapWidth-document.discret;
+   if (y<document.snap) y=0;  else if (y>=document.mapHeight-document.snap) y=document.mapHeight-document.discret;
+
+   document.firstY=document.discret*Math.round(y/document.discret); 
+   document.firstX=document.discret*Math.round(x/document.discret);
+   if ((document.firstY + document.sizeY)>document.mapHeight) document.sizeY =- document.sizeY;
+   if ((document.firstX + document.sizeX)>document.mapWidth)  document.sizeX =- document.sizeX;
+   g2n();
+
+   document.dragging=true;
+
+}
+
+function  commonMouseUp   () {
+ endDragging();
+}
+
+
+
+
+
+function initDragging()
+{
+  if (!document.dragEn) {
+    if(isDOM) {
+	 if (!isOperaIE) {
+       document.getElementById("mapImage").addEventListener("mousemove", dragging_Mozilla, true);
+       document.getElementById("mapImage").addEventListener("mousedown", mouseDown_Mozilla, true);
+       document.getElementById("mapImage").addEventListener("mouseup",   mouseUp_Mozilla, true);
+     } else {
+       document.getElementById("mapImage").onmousemove= dragging_Opera;
+       document.getElementById("mapImage").onmousedown= mouseDown_Opera;
+       document.getElementById("mapImage").onmouseup=   mouseUp_Opera ;
+	 }
+    }
+    else alert ("incompartible browser");
+    document.getElementById("window_selection").style.borderColor= "#00ff00";
+    document.dragEn=true;
+  }
+
+}
+function endDragging()
+{
+ document.dragging=false;
+  if (document.dragEn) {
+    if(isDOM) {
+	 if (!isOperaIE) {
+      document.getElementById("mapImage").removeEventListener("mousemove", dragging_Mozilla, true);
+      document.getElementById("mapImage").removeEventListener("mousedown", mouseDown_Mozilla, true);
+      document.getElementById("mapImage").removeEventListener("mouseup",   mouseUp_Mozilla, true);
+     } else {
+       document.getElementById("mapImage").onmousemove= null;
+       document.getElementById("mapImage").onmousedown= null;
+       document.getElementById("mapImage").onmouseup=   null;
+	 }
+    }
+
+    else alert ("incompartible browser");
+    document.dragEn=false;
+    document.getElementById("window_selection").style.borderColor= "#ff0000";
+  }
+}
+
+function updateColor(){
+ document.commonOptions=document.defaultOptions;
+ if (document.getElementById("idColor").checked)document.commonOptions+="c";
+ if (document.flipX) document.commonOptions+="x";
+ if (document.flipY) document.commonOptions+="y";
+// alert ("updateColor: document.commonOptions="+document.commonOptions);
+ updateLinks();
+}
+
+function updateGamma(){
+var g;
+ g=parseFloat(document.getElementById("idGamma").value);
+ if (!((g>=0.13)&&(g<=10))) document.getElementById("idGamma").value=0.47;
+  updateLinks();
+}
+
+// document.getElementById("idLevelBlack").value=2;
+// document.getElementById("idLevelWhite").value=254;
+function updateLevels(){
+  var vb,vw;
+  vb=parseInt(document.getElementById("idLevelBlack").value);
+  if (!((vb>=0)&&(vb<=254))) {
+    vb=0;
+    document.getElementById("idLevelBlack").value=0;
+  }  
+  vw=parseInt(document.getElementById("idLevelWhite").value);
+  if (!((vw>=vb)&&(vw<=255))) document.getElementById("idLevelWhite").value=255;
+ 
+}
+
+
+
+function updateGains(){
+var g;
+ g=parseInt(document.getElementById("idGainY").value); if (!((g>=0)&&(g<=63))) document.getElementById("idGainY").value=20;
+ g=parseInt(document.getElementById("idGainR").value); if (!((g>=0)&&(g<=63))) document.getElementById("idGainR").value=20;
+ g=parseInt(document.getElementById("idGainG").value); if (!((g>=0)&&(g<=63))) document.getElementById("idGainG").value=20;
+ g=parseInt(document.getElementById("idGainB").value); if (!((g>=0)&&(g<=63))) document.getElementById("idGainB").value=20;
+  updateLinks();
+}
+function updateExposure(){ //now it is measured in 100uS
+//  var e=parseInt(document.getElementById("idExposure").value); if (!((e>0)&&(e<10000))) document.getElementById("idExposure").value=20;
+  var e=parseFloat(document.getElementById("idExposure").value); if (!((e>0)&&(e<10000))) e=20;
+    e=Math.round (10*e)/10;document.getElementById("idExposure").value=e;
+
+//  document.saveExposure=parseInt(document.getElementById("idExposure").value);
+  document.saveExposure=parseFloat(document.getElementById("idExposure").value);
+  document.getElementById("idFrameTime").checked=false;
+  updateLinks();
+}
+function updateFullFrameExposure(){
+  document.getElementById("idExposure").value=(document.getElementById("idFrameTime").checked)?"":document.saveExposure;
+  updateLinks();
+}
+function updateQuality(){
+  var v=v=parseInt(document.getElementById("idQuality").value);
+  if (!((v>0)&&(v<=100))) document.getElementById("idQuality").value=50;
+  updateLinks();
+}
+function updateSaturation(m){ // m=0 - set both (from blue), m=1 - red only
+  var v;
+   if (m>0) {
+     v=parseFloat(document.getElementById("idSaturationRed").value);
+     if (!((v>=0)&&(v<=5))) v=1.0;
+     document.getElementById("idSaturationRed").value=v;
+   } else {
+     v=parseFloat(document.getElementById("idSaturationBlue").value);
+     if (!((v>=0)&&(v<=5))) v=1.0;
+     document.getElementById("idSaturationBlue").value=v;
+     document.getElementById("idSaturationRed").value=v;
+   }     
+  updateLinks();
+}
+function updateVideoSize(){
+      v=parseInt(document.getElementById("idTimeScale").value); if (!((v>0)&&(v<1000))) document.getElementById("idTimeScale").value=10;
+      v=parseInt(document.getElementById("idTheoraFrames").value); if (!((v>0)&&(v<65536))) document.getElementById("idTheoraFrames").value=40;
+      v=parseInt(document.getElementById("idTheoraInter").value); if (!((v>=0)&&(v<256))) document.getElementById("idTheoraInter").value=255;
+  updateLinks();
+}
+function showControls(){
+ var w;
+    w=window.open('vcontrols.html',
+                  'Controls'+escape(document.URL),
+                  'resizable=no,scrollbars=no,status=no,alwaysRaised=yes,height=335,width=100' );
+   w.focus();
+}
+function showClipFrame(){
+//    var w=window.open('clip_frame.html',
+//                  'Frame'+escape(document.URL),
+//                  'resizable=no,scrollbars=no,status=no,alwaysRaised=yes,'+
+//                  'height='+(100+parseInt(document.getElementById('idHeight').value))+
+//                  'width='+(20+parseInt(document.getElementById('idWidth').value)) );
+//   w.focus();
+  acquireIfCan("var w=window.open('clip_frame.html'," +
+               "'Frame'+escape(document.URL)," +
+               "'resizable=no,scrollbars=no,status=no,alwaysRaised=yes,'+" +
+               "'height='+(100+parseInt(document.getElementById('idHeight').value))+ "+
+               "'width='+(20+parseInt(document.getElementById('idWidth').value)) ); "+
+               "w.focus();" );
+
+}
+
+function updateLinks(){
+   var t=new Date();
+   var g;
+   var e=Math.round (parseFloat(document.getElementById("idExposure").value)*10); // 10 times actual
+   var requestedFPS;
+   updateFPS();
+   requestedFPS=parseFloat(document.getElementById("idRequestedFPS").value);
+   if (!(requestedFPS>0)){
+     requestedFPS=0;
+     document.getElementById("idRequestedFPS").value=" ";
+   }
+   var dcms="&dv="+document.dcm+"&dh="+document.dcm+"&";
+   document.commonParameters ="iq="+parseInt(document.getElementById("idQuality").value)+"&"+
+                              "kga="+parseInt(document.getElementById("idGainY").value)+"&"+
+                              "kgm=6&"+
+                              "gr="+ parseInt(document.getElementById("idGainR").value)+"&"+
+                              "gg="+ parseInt(document.getElementById("idGainG").value)+"&"+
+                              "ggb="+parseInt(document.getElementById("idGainG").value)+"&"+
+                              "gb="+ parseInt(document.getElementById("idGainB").value)+"&"+
+                              "csb="+Math.round(100*parseFloat(document.getElementById("idSaturationBlue").value))+"&"+
+                              "csr="+Math.round(100*parseFloat(document.getElementById("idSaturationRed").value))+"&"+
+                              "bit=8"+"&"+
+                              "gam="+Math.round(100*parseFloat(document.getElementById("idGamma").value))+"&"+
+                              "pxl="+parseInt(document.getElementById("idLevelBlack").value)+"&"+
+                              "pxh="+parseInt(document.getElementById("idLevelWhite").value);
+   if (!document.getElementById("idFrameTime").checked)
+     document.commonParameters+="&e="+e;
+   else document.commonParameters+="&e=-1";
+/*
+   document.previewURL=document.cgi+"opt="+document.commonOptions+
+//         "&dv=2&dh=2&ww=1280&wh=1024&wl=0&wt=0&"+
+
+         "&dv="+document.previewDecimation+"&dh="+document.previewDecimation+"&ww="+document.maxWidth+"&wh="+document.maxHeight+"&wl=0&wt=0&"+
+         document.commonParameters+
+         "&fps="+ requestedFPS+
+         "&_time="+t.getTime();
+*/
+   document.previewURL="/pics/nopreview.gif";
+   
+   
+   document.probeURL=document.cgi+"opt="+document.commonOptions+
+         "&dv=1&dh=1&ww=2100&wh=2100&wl=0&wt=0&iq=1"+"&_time="+t.getTime();
+
+  document.commonParameters+= "&ww="+ parseInt(document.getElementById("idWidth").value)+"&"+
+                              "wh="+ parseInt(document.getElementById("idHeight").value)+"&"+
+                              "wl="+ parseInt(document.getElementById("idLeft").value)+"&"+
+                              "wt="+ parseInt(document.getElementById("idBottom").value);
+//new/new win will be ogg/theora
+   document.newWinURL= document.cgi+"opt=o"+document.commonOptions+dcms+
+                       document.commonParameters+
+                       "&fps="+ requestedFPS+
+                       "&tts="+ parseInt(document.getElementById("idTimeScale").value)+
+                       "&tnf="+ parseInt(document.getElementById("idTheoraFrames").value)+
+                       "&tni="+ parseInt(document.getElementById("idTheoraInter").value)+
+                       "&_time="+t.getTime();
+   document.updateURL= document.cgi+"opt="+document.commonOptions+"u"+dcms+
+                       document.commonParameters+
+                       "&fps="+ requestedFPS+
+                       "&_time="+t.getTime();
+
+  document.startStopClipURL=document.cgi+"opt="+document.commonOptions+"q"+dcms+document.commonParameters+
+                              "&qts="+ parseInt(document.getElementById("idTimeScale").value)+
+                              "&fps="+ requestedFPS+
+                              "&_time="+t.getTime()+"&qcmd=";
+   document.getElementById('idStillPhoto').href=document.newWinURL;
+   document.getElementById('idLastPhoto').href=document.cgi+"opt=o"+"&_time="+t.getTime();
+//   document.getElementById('idFrame').href=document.cgi+"hist="+document.clipFrame+"&_time="+t.getTime();
+   document.getElementById('idInfo').href=document.cgi+"html=2"+"&_time="+t.getTime();
+
+/*   document.getElementById('idClip').href=document.cgi+"opt="+document.commonOptions+"q"+dcms+document.commonParameters+
+                              "&qcmd=4"+
+                              "&qts="+ parseInt(document.getElementById("idTimeScale").value)+
+                              "&fps="+ requestedFPS+
+                              "&_time="+t.getTime();*/
+  document.loadXMLDocURL=document.cgi+"html=10&_time="+t.getTime();
+  document.loadXMLStateURL=document.cgi+"html=12&_time="+t.getTime();
+  document.rescueURL=document.cgi+"opt=*q&qcmd=2&_time="+t.getTime(); // unfreeze
+  document.setTimeURL=document.cgi+"_time="+t.getTime(); // unfreeze
+}
+function updateClipFrame(v){
+  if ((v<9999) && (v>-9999)) document.clipFrame=v;
+  document.getElementById("idClipFrame").value=document.clipFrame;
+  updateLinks();
+}
+function changeClipFrame(m) { // m=-2 - first, m=-1 - prev, +1 - next, +2 - last
+  if      (m==-2) document.clipFrame= 1; //first
+  else if (m==-1) document.clipFrame-=1; //previous
+  else if (m== 1) document.clipFrame+=1; //next
+  else if (m== 2) document.clipFrame=0; //last
+  updateClipFrame(document.clipFrame);
+}
+function clipStartStop(c) {
+  updateLinks();
+  document.dummyImg.src=document.startStopClipURL+c;
+}
+function updateParameters() {
+  updateLinks();
+  document.dummyImg.src=document.updateURL;
+}
+function cameraReset() {
+  updateLinks();
+  document.dummyImg.src=document.rescueURL;
+}
+function setTimeIf1972(){
+  updateLinks();
+  document.dummyImg
+  document.dummyImg.onload=updateXML;
+  document.dummyImg.src=document.setTimeURL;
+//  alert(document.dummyImg.src);
+}
+function getFromCamera(){
+   document.imageGot=1;
+   document.maxWidth=                        parseInt(req.responseXML.getElementsByTagName('P_SENSOR_WIDTH' )[0].firstChild.nodeValue);
+   document.maxHeight=                       parseInt(req.responseXML.getElementsByTagName('P_SENSOR_HEIGHT')[0].firstChild.nodeValue);
+// don't read decimation - it will likely be from the perview
+// document.dcm=                             parseInt(req.responseXML.getElementsByTagName('P_DCM_HOR'      )[0].firstChild.nodeValue);
+   
+   document.getElementById("idDCM8").checked=(document.dcm>=8);
+   document.getElementById("idDCM4").checked=((document.dcm>=4) && (document.dcm<8));
+   document.getElementById("idDCM2").checked=((document.dcm>=2) && (document.dcm<4));
+   document.getElementById("idDCM1").checked=                      (document.dcm<2);
+   document.getElementById("idGainY").value= parseInt(req.responseXML.getElementsByTagName('P_SPEC_KAC_GGA' )[0].firstChild.nodeValue);
+   document.getElementById("idGainR").value= parseInt(req.responseXML.getElementsByTagName('P_GAINR'        )[0].firstChild.nodeValue);
+   document.getElementById("idGainG").value= parseInt(req.responseXML.getElementsByTagName('P_GAING'        )[0].firstChild.nodeValue);
+   document.getElementById("idGainB").value= parseInt(req.responseXML.getElementsByTagName('P_GAINB'        )[0].firstChild.nodeValue);
+
+   document.getElementById("idWidth").value= parseInt(req.responseXML.getElementsByTagName('P_WOI_WIDTH'    )[0].firstChild.nodeValue);
+   document.getElementById("idHeight").value=parseInt(req.responseXML.getElementsByTagName('P_WOI_HEIGHT'   )[0].firstChild.nodeValue);
+   document.getElementById("idLeft").value=  parseInt(req.responseXML.getElementsByTagName('P_WOI_LEFT'     )[0].firstChild.nodeValue);
+   document.getElementById("idBottom").value=   parseInt(req.responseXML.getElementsByTagName('P_WOI_TOP'      )[0].firstChild.nodeValue);
+   
+   document.flipX= (parseInt(req.responseXML.getElementsByTagName('P_FLIPH')[0].firstChild.nodeValue)>0)?1:0;
+   document.flipY= (parseInt(req.responseXML.getElementsByTagName('P_FLIPV')[0].firstChild.nodeValue)>0)?1:0;
+   document.getElementById("idColor").checked= (parseInt(req.responseXML.getElementsByTagName('P_COLOR')[0].firstChild.nodeValue)>0)?"true":"false";
+   document.getElementById("idGamma").value= 0.01*parseInt(req.responseXML.getElementsByTagName('P_GAMMA'        )[0].firstChild.nodeValue);
+   document.getElementById("idSaturationBlue").value= 0.01*parseInt(req.responseXML.getElementsByTagName('P_COLOR_SATURATION_BLUE')[0].firstChild.nodeValue);
+   document.getElementById("idSaturationRed").value= 0.01*parseInt(req.responseXML.getElementsByTagName('P_COLOR_SATURATION_RED' )[0].firstChild.nodeValue);
+
+   document.getElementById("idLevelBlack").value=parseInt(req.responseXML.getElementsByTagName('P_PIXEL_LOW' )[0].firstChild.nodeValue);
+   document.getElementById("idLevelWhite").value=parseInt(req.responseXML.getElementsByTagName('P_PIXEL_HIGH')[0].firstChild.nodeValue);
+
+   
+   document.getElementById("idQuality").value= parseInt(req.responseXML.getElementsByTagName('P_QUALITY'      )[0].firstChild.nodeValue);
+   document.getElementById("idExposure").value= 0.1*parseInt(req.responseXML.getElementsByTagName('P_EXPOS'   )[0].firstChild.nodeValue);
+   document.previewDecimation=(document.maxWidth>1600)?4:2;
+
+   document.getElementById('mapImage').style.width=document.maxWidth/document.previewDecimation;
+   document.getElementById('mapImage').style.height=document.maxHeight/document.previewDecimation;
+   document.getElementById('idControls').style.top=document.maxHeight/document.previewDecimation+8;
+   if (document.previewDecimation==2)    document.getElementById('idControls').style.width=document.maxWidth/document.previewDecimation;
+   document.mapWidth= document.maxWidth/document.previewDecimation;
+   document.mapHeight=document.maxHeight/document.previewDecimation;
+//   fullWindow();
+// read defaults if sensor was never programmed 
+   document.sensor=parseInt(req.responseXML.getElementsByTagName('P_SENSOR' )[0].firstChild.nodeValue);
+   if ((!(parseInt(req.responseXML.getElementsByTagName('SENSOR_STATE' )[0].firstChild.nodeValue)>0)) ||
+       (!(parseInt(req.responseXML.getElementsByTagName('P_QUALITY' )[0].firstChild.nodeValue)>0))) {
+         setDefaults();
+   }
+//    else updateLinks();
+   updateColor();
+   updateNumWindow();
+   if (parseInt(req.responseXML.getElementsByTagName('SENSOR_STATE' )[0].firstChild.nodeValue)<8) {
+     document.getElementById("mapImage").style.backgroundImage="url("+document.previewURL+")";
+   } else alert("Can not acquire preview image as streamer is possibly running.\n"+
+              "You may want to try to stop it or reset the camera");
+   if ((document.sensor >=49) && (document.sensor <=51))  document.getElementById("idGainY").style.display="none";
+}
+function setDefaults() {
+// common defaults:
+   document.flipX=1;
+   document.flipY=0;
+   document.getElementById("idColor").checked= true;
+   document.getElementById("idGamma").value= 0.47;
+   document.getElementById("idSaturationBlue").value=2.0;
+   document.getElementById("idSaturationRed").value= 2.0;
+
+   document.getElementById("idQuality").value= 46;
+   document.getElementById("idExposure").value= 20.0;
+// default windows:
+  switch (document.sensor) {
+  case 49: MT9M001_dflt(); break;
+  case 50: MT9D001_dflt(); break;
+  case 51: MT9T001_dflt(); break;
+  default: other_dflt();
+  updateColor();
+//  updateLinks();
+  }
+  
+}
+
+function other_dflt() { // MT9M001_dflt()
+ document.getElementById("idGainY").value=63;
+ document.getElementById("idGainR").value=22;
+ document.getElementById("idGainG").value=16;
+ document.getElementById("idGainB").value=17;
+ document.getElementById("idLevelBlack").value=2;
+ document.getElementById("idLevelWhite").value=254;
+
+}
+function MT9M001_dflt() {
+ document.getElementById("idGainY").value=63;
+ document.getElementById("idGainR").value=22;
+ document.getElementById("idGainG").value=16;
+ document.getElementById("idGainB").value=17;
+ document.getElementById("idLevelBlack").value=2;
+ document.getElementById("idLevelWhite").value=254;
+}
+function MT9D001_dflt() {
+ document.getElementById("idGainY").value=63;
+ document.getElementById("idGainR").value=17; //42
+ document.getElementById("idGainG").value=11; //25
+ document.getElementById("idGainB").value=13; //27
+ document.getElementById("idLevelBlack").value=2;
+ document.getElementById("idLevelWhite").value=254;
+}  
+function MT9T001_dflt() {
+ document.getElementById("idGainY").value=63;
+ document.getElementById("idGainR").value=16;
+ document.getElementById("idGainG").value=11;
+ document.getElementById("idGainB").value=12;
+ document.getElementById("idLevelBlack").value=10;
+ document.getElementById("idLevelWhite").value=254;
+}  
+
+function updateNumWindow() { // validate window sizes, show window
+  if      (document.getElementById("idDCM1").checked) document.dcm=1;
+  else if (document.getElementById("idDCM2").checked) document.dcm=2;
+  else if (document.getElementById("idDCM4").checked) document.dcm=4;
+  else if (document.getElementById("idDCM8").checked) document.dcm=8;
+
+//alert('document.dcm='+document.dcm);
+  var w=parseInt(document.getElementById("idWidth").value);
+  var h=parseInt(document.getElementById("idHeight").value);
+  var l=parseInt(document.getElementById("idLeft").value);
+  var b=parseInt(document.getElementById("idBottom").value);
+//alert("w="+w+"\nh="+h+"\nl="+l+"\nt="+t);
+// l >=0, l<(maxWidth-16*document.dcm)
+/*
+  if (l<0) l=0;
+  if (l>=(document.maxWidth-32*document.dcm)) l=document.maxWidth-32*document.dcm;
+  l= 2*document.dcm*Math.floor(l/2/document.dcm);
+  if((l+w)>document.maxWidth) w= document.maxWidth-l;
+  w=16*document.dcm*Math.floor(w/16/document.dcm);
+  if (w<32*document.dcm) w=32*document.dcm;
+  if (t<0) t=0;
+  if (t>=(document.maxHeight-32*document.dcm)) t=document.maxHeight-32*document.dcm;
+  t= 2*document.dcm*Math.floor(t/2/document.dcm);
+  if((t+h)>document.maxHeight) h= document.maxHeight-t;
+  h=16*document.dcm*Math.floor(h/16/document.dcm);
+  if (h<32*document.dcm) h=32*document.dcm;
+*/
+//  document.discret_x=128;
+//  document.discret_y=64;
+  if (l<0) l=0;
+  if (l>=(document.maxWidth- document.discret_x*document.dcm)) l=document.maxWidth- document.discret_x*document.dcm;
+  l= document.dcm*Math.round(l/document.dcm);
+  if((l+w)>document.maxWidth) w= document.maxWidth-l;
+  w=document.discret_x*document.dcm*Math.round(w/document.discret_x/document.dcm);
+  if (w<document.discret_x*document.dcm) w=document.discret_x*document.dcm;
+  if((l+w)>document.maxWidth) l= document.maxWidth-w;
+  if (b<0) b=0;
+  if (b>=(document.maxHeight - document.discret_y*document.dcm)) b=document.maxHeight - document.discret_y*document.dcm;
+  b= document.dcm*Math.round(b/document.dcm);
+  if((b+h)>document.maxHeight) h= document.maxHeight-b;
+  h=document.discret_y*document.dcm*Math.round(h/document.discret_y/document.dcm);
+  if (h<document.discret_y*document.dcm) h=document.discret_y*document.dcm;
+  if((b+h)>document.maxHeight) b= document.maxHeight-h;
+
+
+// update values in the text fields
+  document.getElementById("idWidth").value=w;
+  document.getElementById("idHeight").value=h;
+  document.getElementById("idLeft").value=l;
+  document.getElementById("idBottom").value=b;
+// show graphically (see if needed 1 extra pixel for the border each side)
+  document.getElementById("window_selection").style.width= (w/document.previewDecimation)-2;
+  document.getElementById("window_selection").style.height=(h/document.previewDecimation)-2;
+  document.getElementById("window_selection").style.left=  l/document.previewDecimation;
+//  document.getElementById("window_selection").style.top=   t/document.previewDecimation;
+  document.getElementById("window_selection").style.top=   (document.maxHeight-b-h)/document.previewDecimation;
+//  alert ("w="+w+"\nh="+h+"\nl="+l+"\nb="+b+"\ndocument.previewDecimation="+document.previewDecimation);
+  updateLinks();
+}
+
+function fullWindow() {
+  document.getElementById("idWidth").value=document.maxWidth;
+  document.getElementById("idHeight").value=document.maxHeight;
+  document.getElementById("idLeft").value=0;
+  document.getElementById("idBottom").value=0;
+  updateNumWindow();
+}  
+
+function imgPreview() {
+//  if (document.imageGot==1) {
+    updateLinks();
+    acquireIfCan("document.getElementById('mapImage').style.backgroundImage='url('+document.previewURL+')';");
+
+
+// disable preview
+//    document.getElementById("mapImage").style.backgroundImage="url("+document.previewURL+")";
+//  } else  imgPreview_init();
+}
+
+function imgNewWindow() {
+  updateLinks();
+  var w=parseInt(document.getElementById("idWidth").value)/document.dcm;
+  var h=parseInt(document.getElementById("idHeight").value)/document.dcm;
+//  window.open(document.newWinURL,'image','resizable=yes,scrollbars=yes, width='+(w+40)+',height='+(h+30));
+  var cmd="window.open(document.newWinURL,'image','resizable=yes,scrollbars=yes, width="+(w+40)+",height="+(h+30)+"');"
+  acquireIfCan(cmd);
+
+}
+
+// Mozilla functions
+function mouseDown_Mozilla (e) {
+ if (document.dragging) mouseUp_Mozilla   (e);
+ else commonMouseDown (e.pageX,e.pageY);
+}
+function dragging_Mozilla(e) {commonDragging(e.pageX,e.pageY);}
+function mouseUp_Mozilla   (e) { commonMouseUp   ();}
+// Opera/IE6 functions
+function mouseDown_Opera (e) {
+ if (document.dragging) mouseUp_Mozilla   (e);
+ else commonMouseDown (event.clientX,event.clientY);
+}
+function dragging_Opera(){ commonDragging(event.clientX,event.clientY);}
+function mouseUp_Opera  () {commonMouseUp   ();}
+
+</script>
+<title>Elphel Model 333 Camera with Ogg/Theora</title>
+</head>
+<!--<body  class="textStyle" bgcolor="#CCCCCC" onLoad="setTimeIf1972();updateColor();updateNumWindow();"> -->
+<body  class="textStyle" bgcolor="#CCCCCC" onLoad="updateXML();">
+
+<!--
+<div id="mapImage" style="position:absolute; width:640px; height:512px; z-index:101; left: 0px; top: 0px;  border-style: solid; background-position: top center; background-repeat: no-repeat; border: 1px none #000000">
+-->
+
+<div id="mapImage" style="position:absolute; width:640px; height:512px; z-index:101; left: 0px; top: 0px;  border-style: solid; background-position: top left; background-repeat: repeat; border: 1px none #000000">
+
+
+  <div id="window_selection"></div>
+</div>
+<div id="idControls" style="position:absolute; width:640px; height:200px; z-index:101; left: 0px; top: 520;">
+
+<form method="post" action="">
+    <table border="1" cellspacing="0" cellpadding="0" width="100%">
+      <tr valign="top"> 
+        <td>
+         <table border="1" cellspacing="0" cellpadding="0" width="100%" height="100%">
+         <tr><td>
+          
+          <table border="0" cellspacing="0" cellpadding="0" width="100%">
+            <tr> 
+              <td colspan="2"> 
+                <div align="center"><b>Window</b> </div>
+              </td></tr>
+<!--            <tr><td colspan="2">&nbsp;</td></tr> -->
+              <tr>
+              <td> 
+                <div align="center">
+                  <input type="button" id="idSelectDrag" value="Drag" onClick="initDragging();" >
+                </div>
+              </td>
+              <td> 
+                <div align="center">
+                  <input type="button" id="idSelectFull" value="Full" onClick="fullWindow();" >
+                </div>
+              </td>
+            </tr>
+<!--            <tr><td colspan="2">&nbsp;</td></tr> -->
+
+            <tr> 
+              <td>
+                <div class="nowrap">
+                W<input type="text" id="idWidth" size="4" maxlength="4" value="1280" onChange="updateNumWindow();" class="inputs"></div>
+              </td>
+              <td> 
+                <div class="nowrap">
+                H<input type="text" id="idHeight" size="4" maxlength="4" value="1024" onChange="updateNumWindow();" class="inputs">
+                </div>
+              </td>
+            </tr>
+              <td>
+                <div class="nowrap">
+                L<input type="text" id="idLeft" size="4" maxlength="4" value="0" onChange="updateNumWindow();" class="inputs">
+                </div>
+              </td>
+              <td> 
+                <div class="nowrap">
+                B<input type="text" id="idBottom" size="4" maxlength="4" value="0" onChange="updateNumWindow();" class="inputs">
+                </div>
+                
+              </td>
+            </tr>
+            
+<!--            <tr><td colspan="2">&nbsp;</td></tr> -->
+            <tr><td>
+            </table>
+            </td> </tr>
+            <tr><td>
+             <table border="0"  width= "100%">
+              <tr>
+               <td colspan="4"><div align="center"><b>Decimation</b></div></td>
+              </tr>
+              <tr>
+               <td>none</td><td>1/2</td><td>1/4</td><td>1/8</td>
+              </tr>
+              <tr>
+               <td> <input type="radio" id="idDCM1" name="nDecimation" value="1" onChange="updateNumWindow();" onClick="updateNumWindow();" checked ></td>
+               <td> <input type="radio" id="idDCM2" name="nDecimation" value="2" onChange="updateNumWindow();" onClick="updateNumWindow();"  ></td>
+               <td> <input type="radio" id="idDCM4" name="nDecimation" value="4" onChange="updateNumWindow();" onClick="updateNumWindow();"  ></td>
+               <td> <input type="radio" id="idDCM8" name="nDecimation" value="8" onChange="updateNumWindow();" onClick="updateNumWindow();" c ></td>
+              </tr>
+             </table>
+            </td></tr>
+
+            
+            <tr > 
+              <td>
+               <table><tr>
+                 <td><div style="nowrap"><b>Quality</b></div></td>
+                 <td><div style="nowrap"><input type="text" id="idQuality" size="2" maxlength="2" value="46" onChange="updateQuality();" class="inputs">%</div></td>
+                </tr>
+               </table>
+              </td>
+            </tr>
+
+
+            <tr>
+              <td>
+                <table><tr> 
+                  <td>Rst</td>
+                  <td><input type="radio" id="idReset" name="nReset" value="1" onClick="cameraReset();"></td>
+                  </td>    
+                  <td>
+                  <input type="button" id="idDefault" value="Defaults" onClick="setDefaults();" >
+                </td>
+                </tr></table>
+              </td>
+            </tr>
+          </table>
+      </td>
+        
+
+        
+      <td>
+       <table border="1" cellspacing="0" cellpadding="0" width="100%" height="100%">
+        <tr><td>
+          <table border="0" cellspacing="0" cellpadding="0" width="100%">
+            <tr>
+              <td colspan="2">
+                <div align="center"><b>Exposure</b></div>
+              </td>
+              </tr>
+              <tr>
+              <td>
+                <div align="right">
+                  <input type="text" id="idExposure" size="5" maxlength="5" value="20" onChange="updateExposure();" class="inputs">
+                </div>
+              </td>
+              <td>ms</td>
+            </tr>
+            <tr>
+              <td>
+                <div align="center">1 frame</div>
+              </td>
+              <td>
+                <input type="checkbox" id="idFrameTime" onClick="updateFullFrameExposure()">
+              </td>
+            </tr>
+          </table>
+        </td></tr>
+        <tr><td>  
+          <table border="0" cellspacing="0" cellpadding="0" width="100%">
+            <tr>
+              <td colspan="2">
+                <div align="center"><b>Gains</b>
+<input type="text" id="idGainY" size="3" maxlength="3" value="100" onChange="updateGains();" class="inputs"></div>
+              </td>
+            <tr>
+              <td> 
+                <div align="right">R </div>
+              </td>
+              <td>
+                <input type="text" id="idGainR" size="3" maxlength="3" value="30" onChange="updateGains();" class="inputs">
+              </td>
+            </tr>
+            <tr> 
+              <td> 
+                <div align="right">G </div>
+              </td>
+              <td>
+                <input type="text" id="idGainG" size="3" maxlength="3" value="25" onChange="updateGains();" class="inputs">
+              </td>
+            </tr>
+            <tr> 
+              <td> 
+                <div align="right">B </div>
+              </td>
+              <td>
+                <input type="text" id="idGainB" size="3" maxlength="3" value="30" onChange="updateGains();" class="inputs">
+              </td>
+            </tr>
+            <tr>
+              <td>Color</td>
+              <td >
+                <input type="checkbox" id="idColor" onClick="updateColor()" checked>
+              </td>
+            </tr>
+           </table>
+         </td></tr>
+        </table> 
+      </td>
+
+
+
+      
+        
+      <td>
+       <table border="1" cellspacing="0" cellpadding="0" width="100%" height="100%">
+        <tr><td>
+          <table border="0" cellspacing="0" cellpadding="0" width="100%">
+            
+            <tr>
+              <td colspan="2"><div align="center"><b>Contrast</b></div></td>
+            </tr>
+            <tr>
+              <td>
+                <div align="right">Gamma</div>
+              </td>
+<!--              <td><input type="text" id="idGainY" size="3" maxlength="3" value="30" onChange="updateGains();" class="inputs"></td> --> <!-- KAC1310-->
+              <td><input type="text" id="idGamma" size="4" maxlength="4" value="0.47" onChange="updateGamma();" class="inputs"></td>
+            </tr>
+            
+            <tr>
+              <td>Levels</td><td> </td>
+            </tr>
+            <tr>
+              <td>
+                <div align="right">Black</div>
+              </td>
+              <td><input type="text" id="idLevelBlack" size="4" maxlength="4" value="0" onChange="updateLevels();" class="inputs"></td>
+            </tr>
+            <tr>
+              <td>
+                <div align="right">White</div>
+              </td>
+              <td><input type="text" id="idLevelWhite" size="4" maxlength="4" value="255" onChange="updateLevels();" class="inputs"></td>
+            </tr>
+
+          </table>
+        </td></tr>
+        <tr><td>
+          <table border="0" cellspacing="0" cellpadding="0" width="100%">
+            <tr>
+              <td colspan="2"><div align="center"><b>Saturation</b></div></td>
+            </tr>
+            <tr>
+              <td>
+                <div align="right">B-Y</div>
+              </td>
+              <td><input type="text" id="idSaturationBlue" size="4" maxlength="4" value="2.0" onChange="updateSaturation(0);" class="inputs"></td>
+            </tr>
+            <tr>
+              <td>
+                <div align="right">R-Y</div>
+              </td>
+              <td><input type="text" id="idSaturationRed" size="4" maxlength="4" value="2.0" onChange="updateSaturation(1);" class="inputs"></td>
+            </tr>
+            
+
+            
+          </table>
+        </td></tr>
+       </table>
+      </td>
+
+
+
+        
+        <td>
+          <table border="1" cellspacing="0" cellpadding="0" width="100%" height="100%">
+            <tr>
+              <td><table border="0" cellspacing="0" cellpadding="0" width="100%" >
+            <tr>
+              <td colspan="2" nowrap="y">
+
+                              <b> Theora Clip: <a id="idStillPhoto" href="#" target="_blank">New</a> : </b>
+                              <b><a id="idLastPhoto" href="#" target="_blank">Last</a></b>
+                             <b><a id="idInfo" href="#" target="_blank">?</a></b> : 
+                             <b><a href="index_help.html" target="_blank">HELP</a></b></div>
+
+                      
+              </td>
+            </tr>
+<!--
+            <tr>
+                    <td>
+                      <div align="center">
+                        <input type="button" id="idPreview" value="Preview" onClick="imgPreview();" >
+                      </div>
+                    </td><td>
+                      <div align="center">
+                        <input type="button" id="idGet" value="Separate window" onClick="imgNewWindow();" >
+                      </div>
+                    </td>
+</tr>          </table></td>
+            </tr>
+-->
+            <tr>
+              <td>
+                <table border="0" cellspacing="0" cellpadding="0" width="100%" >
+<!--
+                  <tr>
+                    <td colspan="2">
+                      <div align="center">
+                        <b><a id="idClip" href="#" target="_blank">Video Clip</a></b>&nbsp;&nbsp;
+                        <b><a id="idClip" href="strctl.cgi" target="_blank">Video Streamers</a></b>
+                      </div>
+                    </td>
+                  </tr>
+
+                  <tr>
+                    <td colspan="2">
+                        <input type="button" id="idStart" value="Start" onClick="clipStartStop(1);" >
+                        <input type="button" id="idStop" value="Stop" onClick="clipStartStop(2);" >
+                        <input type="button" id="idAcquire" value="Acquire" onClick="clipStartStop(3);" >
+                    </td>
+                  </tr>
+              <tr>
+              <tr>
+                <td> <div align="left">
+                    <input type="button" id="idUpdate" value="Update" onClick="updateParameters();" >
+                </div></td>
+                <td>
+                    <input type="button" id="idVcontrols" value="Video Controls" onClick="showControls();" >
+                </td>
+              </tr>
+-->
+              <tr>
+                <td> <div align="left">
+                    Frame rate
+                </div></td>
+                <td>
+                   <input type="text" id="idRequestedFPS" size="5" maxlength="5" value=" " onChange="updateVideoSize();" class="inputs">
+                   fps
+                </td>
+              </tr>
+              <tr>
+                <td> <div align="left">
+                   Time Scale
+                </div></td>
+                <td>
+                   <input type="text" id="idTimeScale" size="3" maxlength="3" value="3" onChange="updateVideoSize();" class="inputs">
+                   x
+                </td>
+              </tr>
+              <tr>
+                <td> <div align="left">
+                   Tot. frames
+                </div></td>
+                <td>
+                   <input type="text" id="idTheoraFrames" size="5" maxlength="5" value="100" onChange="updateVideoSize();" class="inputs">
+                </td>
+              </tr>
+              <tr>
+                <td> <div align="left">
+                   INTER/INTRA
+                </div></td>
+                <td>
+                   <input type="text" id="idTheoraInter" size="3" maxlength="3" value="255" onChange="updateVideoSize();" class="inputs">
+                </td>
+              </tr>
+<!--
+              <tr>
+                <td colspan="2">
+                <input type="button" id="idFBack" value="<<" onClick="changeClipFrame(-2);" >
+                <input type="button" id="idBack" value="<" onClick="changeClipFrame(-1);" >
+                  <input type="text" id="idClipFrame" size="4" maxlength="4" value="0" onChange="updateClipFrame(this.value);" class="inputs">
+                <input type="button" id="idFrw" value=">" onClick="changeClipFrame(1);" >
+                <input type="button" id="idFFrw" value=">>" onClick="changeClipFrame(2);" >
+                </td>
+              </tr>
+              <tr><td colspan="2">
+                <input type="button" id="idShowClipFrame" value="Show clip frame" onClick="showClipFrame();" >
+                 <b><a id="idFrame" href="#" target="_blank">Frame</a></b>              
+              </td></tr>
+-->
+                </table>
+</td>
+            </tr>
+
+          </table>
+        </td>
+    </tr>
+<!-- Video streamer -->
+            <tr>
+              <td>
+                <table border="0" cellspacing="0" cellpadding="0" width="100%" >
+                  <tr>
+                    <td colspan="2">
+                      <div align="center"><b>Theora RTP
+                        Streamer</b>
+                        <img src="pics/1pix.jpeg" width="1" height="1" name="n1pix" id="id1pix">
+                      </div>
+                    </td>
+                  </tr>
+                  <tr>
+                    <td>
+                        <input type="button" id="idStartStrm" value="Start streaming" onClick="StreamerStartStop(1);" >
+                    </td>
+                    <td>
+                        <input type="button" id="idStopStrm" value="Stop streaming" onClick="StreamerStartStop(0);" >
+                    </td>
+                 </tr>
+                 <tr>
+                    <td>
+                      <div align="right">Addr/hostname</div>
+                    </td>
+                    <td> 
+                      <input type="text" id="idAddress" size="15" maxlength="15" value="239.0.0.1" onChange="updateAddress();" class="inputs" name="text">
+                    </td>
+                  </tr>
+                  <tr> 
+                    <td>
+                      <div align="right">Port#</div>
+                    </td>
+                    <td> 
+                      <input type="text" id="idPort" size="5" maxlength="5" value="20000" onChange="updatePort();" class="inputs" name="text">
+                    </td>
+		   </tr>
+
+	      </td>
+	     </tr>
+
+          </table>
+        </td>
+    </tr>
+
+  </table>
+</form>
+</div>
+</body>
+</html>

Added: experimental/j/Elphel333/rtp/daemon/.target-makefrag
===================================================================
--- experimental/j/Elphel333/rtp/daemon/.target-makefrag	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/.target-makefrag	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1 @@
+AXIS_BUILDTYPE=cris-axis-linux-gnu

Added: experimental/j/Elphel333/rtp/daemon/Makefile
===================================================================
--- experimental/j/Elphel333/rtp/daemon/Makefile	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/Makefile	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,46 @@
+#
+# Makefile for the Elphel streamer.
+# This probably requires GNU make.
+#
+AXIS_USABLE_LIBS = UCLIBC GLIBC
+include $(AXIS_TOP_DIR)/tools/build/Rules.axis
+
+THEORACOMMON=../../common
+THEORACOMMON_OBJS=$(THEORACOMMON)/oggtheora.o $(THEORACOMMON)/utils.o
+
+# Location of includes and library
+CSRC   = rtp
+
+# Library name
+LNAME  = uclmmbase
+
+DEFS   = -DHAVE_CONFIG_H
+CFLAGS = -O2 -W  -Wwrite-strings -Wbad-function-cast -Wmissing-prototypes -Wcast-qual -Wmissing-declarations  $(DEFS) -I$(CSRC) -I$(THEORACOMMON)
+LIBS   = -lm -L$(CSRC)/.libs -l$(LNAME) 
+
+LD	= ld-cris
+
+TARGET = TheoraStrm
+OBJS   = TheoraStrm.o
+SRCS   = $(OBJS:%.o=%.c)
+
+all: $(TARGET)
+
+$(TARGET): $(OBJS) $(CSRC)/lib$(LNAME).a  $(THEORACOMMON_OBJS)
+	 $(CC) $(CFLAGS) -o $@ $(OBJS) $(THEORACOMMON_OBJS) $(LIBS)
+	 strip-cris $@
+
+.c.o:
+	$(CC) $(CFLAGS) $(INC) -c $<
+
+$(THEORACOMMON_OBJS): 
+	cd $(THEORACOMMON) && $(MAKE)
+
+$(CSRC)/lib$(LNAME).a:
+	cd $(CSRC) && $(MAKE)
+
+clean:
+	-rm -f *.o $(OBJS) $(TARGET)
+
+distclean: clean
+	-rm -f Makefile

Added: experimental/j/Elphel333/rtp/daemon/README
===================================================================
--- experimental/j/Elphel333/rtp/daemon/README	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/README	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,8 @@
+note:
+    due to brokenness of rtp lib for cross compile you have to run:
+      cd ntp
+      ./configure && ./configure --host=cris --build=i586-linux 
+      make
+      cd ..
+    make will fail, ingore that and run make
+    

Added: experimental/j/Elphel333/rtp/daemon/TheoraStrm.c
===================================================================
--- experimental/j/Elphel333/rtp/daemon/TheoraStrm.c	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/TheoraStrm.c	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,668 @@
+/******************************************************************************
+This is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+	
+******************************************************************************/
+// Streamer for Elphel Camera 333 input device
+// Copyright (c) 2005 Andy Latin 
+// All rights reserved.
+//
+// http://andy.qnx.org.ru
+// mail to:  
+// andy at qnx.org.ru   
+// andrey.latin at gmail.com
+/////////////////////////////////////////////////////////////////////////////
+#include <sys/time.h>
+#include <sys/mman.h>           /* mmap */
+#include <ctype.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <getopt.h>
+
+#include "c313a.h"
+
+
+/*************** RTP UCL library *******************/
+#include "uclconf.h"
+#include "config_unix.h"
+#include "config_win32.h"
+#include "debug.h"
+#include "memory.h"
+#include "rtp.h"
+
+#include "defines.h"
+#include "oggtheora.h"
+
+#define D(x) 
+
+#define HDR_INTERVAL   100   // send headers every 4 s for  25 fps
+///////////////////// GLOBAL DATA ///////////////////
+int			mTimeinterval = 40000;  // default for 25 fps
+const char 		mmapFileName[]= "/var/tmp/mmap_strm";
+strm_data_t  		*strm_data;
+static strm_data_t  	strm_data_par;
+int			hdr_size;
+/////////////// OggTheora data///////////////////////
+
+ int        kfgshiftm=9;
+ len_data_t packets[6];
+ u_int32_t  header_lengths[6];
+ uint8_t    *b_headers;
+
+/////////////////////////////////////////////////////
+
+static void
+usage()
+{
+    printf("\n");
+    printf("\tTheora RTP streamer for Elphel Camera model 333. \n");
+    printf("\tInitial version writed by: Andrey Latin\n");
+    printf("\nTheoraStrm 0.5 (C) 2005 Elphel Team\n\n");
+    printf("\nThis is distributed in the hope that it will be useful,\n");
+    printf("\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\n");
+    printf("\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n");
+    printf("\nGNU General Public License for more details.\n\n");
+
+    printf("\n\tUsage: TheoraStrm [-f <fps>] [-a <address>] [-p <port>] [-w] [-h]\n\n");
+    printf("\t\t[-w] - use WEB interface for manage streamer\n\n");
+
+    printf("\t If used WEB interface for manage of streamer, options enumerated\n");
+    printf("\t below can be changed from browser.\n\n");
+    
+    printf("\t\t[-f<fps>] - max values fps(frame per second), default 25.\n");
+    printf("\t\tRange from 1 to 30 fps.\n");
+    printf("\t\t[-a<address>] - Unicast or multicast address for streaming RTP\n");
+    printf("\t\t\tDefault 239.0.0.1\n");
+
+    printf("\t\t[-p<port>] - port for streaming data. Must be EVEN!\n");
+    printf("\t\t\tDefault 20000.\n");
+
+    printf("\t\t[-k<password>] - set encryption mode with key <password> (DES)\n");
+    printf("\t\t[-h]  - this help\n\n");
+  exit(-1);
+}
+
+
+/* ------------------------------------------------------------------------- */
+/* RTP callback related */
+
+static void
+sdes_print(struct rtp *session, uint32_t ssrc, rtcp_sdes_type stype) {
+	const char *sdes_type_names[] = {
+		"end", "cname", "name", "email", "telephone", 
+		"location", "tool", "note", "priv"
+	};
+	const uint8_t n = sizeof(sdes_type_names) / sizeof(sdes_type_names[0]);
+
+	if (stype > n) {
+		/* Theoretically impossible */
+		printf("boo! invalud sdes field %d\n", stype);
+		return;
+	}
+	
+	printf("SSRC 0x%08x reported SDES type %s - ", ssrc, 
+	       sdes_type_names[stype]);
+
+	if (stype == RTCP_SDES_PRIV) {
+		printf("don't know how to display.\n");
+	} else {
+		printf("%s\n", rtp_get_sdes(session, ssrc, stype));
+	}
+}
+
+static void
+packet_print(struct rtp *session, rtp_packet *p) 
+{
+	printf("Received data (payload %d timestamp %06d size %d) ", 
+		p->rtp_pak_pt, p->rtp_pak_ts, p->rtp_data_len);
+
+	if (p->rtp_pak_ssrc == rtp_my_ssrc(session)) {
+		/* Unless filtering is enabled we are likely to see
+		   out packets if sending to a multicast group. */
+		printf("that I just sent.\n");
+	} else {
+		printf("from SSRC 0x%08x\n", p->rtp_pak_ssrc); 
+	} 
+}
+
+static void
+rtp_event_handler(struct rtp *session, rtp_event *e) 
+{
+	rtp_packet	*p;
+	rtcp_sdes_item	*r;
+
+	switch(e->type) {
+	case RX_RTP: 
+		p = (rtp_packet*)e->data;
+		packet_print(session, p);
+		xfree(p); /* xfree() is mandatory to release RTP packet data */
+		break;
+	case RX_SDES:
+		r = (rtcp_sdes_item*)e->data;
+		sdes_print(session, e->ssrc, r->type);
+		break;
+	case RX_BYE:
+		break;
+	case SOURCE_CREATED:
+		printf("New source created, SSRC = 0x%08x\n", e->ssrc);
+		break;
+	case SOURCE_DELETED:
+		printf("Source deleted, SSRC = 0x%08x\n", e->ssrc);
+		break;
+	case RX_SR:
+	case RX_RR:
+	case RX_RR_EMPTY:
+	case RX_RTCP_START:
+	case RX_RTCP_FINISH:
+   		free(e->data);
+		break;
+	case RR_TIMEOUT:
+		printf("RR_TIMEOUT\n");
+   		free(e->data);
+		break;
+	case RX_APP:
+		printf("RX_APP\n");
+   		free(e->data);
+		break;
+	}
+	fflush(stdout);
+}
+
+
+//////////////////////////////////////////////////////////////////
+// make RTP packets from Theora and send it 			//
+//////////////////////////////////////////////////////////////////
+static void
+rtp_SendTheoraFrame( struct rtp* session, uint32_t rtp_ts,
+                   uint8_t *theora_data, uint32_t len, uint8_t type_frame)
+{
+       uint8_t rtp_packet_buf[BUF_SIZE],*ptr;
+
+	uint32_t	lastPacket,dataOffset;
+        uint32_t 	bytesToSend,payloadLength,payload_len;
+	int	m_first;
+
+        ptr=&rtp_packet_buf[2];
+	rtp_packet_buf[0]=0x0;
+	rtp_packet_buf[1]=type_frame;
+	m_first = 1;
+	lastPacket = 0;	
+	bytesToSend   = len ; 
+	dataOffset    = 0;
+        D(printf("data len %u \n",len);)
+        // first buffer for sending has 2 byets and DATA
+	// we fill buffer manualy
+        if(len <= BUF_SIZE-2) {
+		memcpy(ptr, theora_data, len);
+        	 rtp_send_data(session, rtp_ts, RTP_PT_THEORA, lastPacket,
+ 		   0, NULL, rtp_packet_buf , len+2 , NULL, 0, 0);
+		return;
+	}
+	else { 
+	     memcpy(ptr,theora_data,BUF_SIZE-2);
+       	     rtp_send_data(session, rtp_ts, RTP_PT_THEORA, lastPacket,
+	   	0, NULL, rtp_packet_buf , BUF_SIZE , NULL, 0, 0);
+        }
+
+	payloadLength = BUF_SIZE;
+        ptr = theora_data+BUF_SIZE-2;
+	dataOffset = dataOffset + BUF_SIZE -2;	
+
+	do {
+         payload_len  = min(payloadLength,bytesToSend - dataOffset);
+
+	 if(  payload_len < payloadLength) 
+	      lastPacket = 1;
+	 else
+	      lastPacket = 0;
+
+       	 rtp_send_data(session, rtp_ts, RTP_PT_THEORA, lastPacket,
+	   0, NULL, ptr , payload_len , NULL, 0, 0);
+ 
+  	ptr += payload_len;
+	dataOffset += payload_len;
+	 
+	} while (dataOffset < bytesToSend);
+
+}
+
+// SEND  headers to clients. It is Not RFC!!!!!!!!!!!!!!!
+static void 
+rtp_SendTheoraHdrs(struct rtp* session, uint32_t rtp_ts,
+		uint8_t *header_data,uint16_t len)
+{
+       uint8_t *ptr;
+
+	int	lastPacket,dataOffset;
+        int 	bytesToSend,payloadLength,payload_len;
+
+        ptr = header_data;
+
+        header_data[0] = 0x80;// it is NOT RFC !!! First byte in packet identification Headers	
+	bytesToSend   = len;
+	dataOffset    = 0;
+	payloadLength = BUF_SIZE;
+
+	do {
+         payload_len  = min(payloadLength,bytesToSend - dataOffset);
+
+	 if(  payload_len < payloadLength) 
+	      lastPacket = 1;
+	 else
+	      lastPacket = 0;
+
+//	 if(lastPacket) hdr_ptr->F_bit=1;
+
+	 rtp_send_data(session, rtp_ts, RTP_PT_THEORA, lastPacket,
+	   0, NULL, ptr + dataOffset , payload_len , NULL, 0, 0);
+	 
+	  dataOffset += payload_len;
+	 
+	} while (dataOffset < bytesToSend);
+
+}
+
+
+int make_OggTheoraHdrs(const char *headers_filename)
+{
+     FILE      *headers_file;
+     u_int32_t  num_headers;
+     int        i,r;
+     struct stat     f_stat;
+
+    if ((headers_file = fopen(headers_filename, "r"))==NULL)
+       {fprintf(stderr,"error opening file %s for reading - error = %d (%s)\n",headers_filename,errno,strerror(errno)); return -1;}
+    if (fread (&num_headers,   4, 1, headers_file)<1) return -4;
+    if (num_headers!=6) return -5;
+    if (fread (header_lengths, 4, 6, headers_file)<6) return -5;
+    if (fread (&kfgshiftm,     4, 1, headers_file)<1) return -5;
+
+    for (i=0;i<3;i++) packets[i].len=header_lengths[i]>>3; // now - in bytes
+    for (i=3;i<6;i++) packets[i].len=header_lengths[i]; // these are needed to be in bits
+    for (i=0;i<6;i++) {
+      header_lengths[i]=(header_lengths[i]+31)>>5;
+      packets[i].data=malloc(header_lengths[i]<<2);
+      if (((r=fread (packets[i].data, 4, header_lengths[i], headers_file))) < (int)header_lengths[i]) {
+		 fprintf(stderr, "i=%d, fread returned %d, wanted - %d\n",i, r,header_lengths[i]);
+		 return -6;
+	   }	 
+    }
+    fclose(headers_file);
+    stat(headers_filename,&f_stat);
+    hdr_size = f_stat.st_size;
+    //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+    // draft realese - TODO for RFC future
+    b_headers = (uint8_t *)malloc(hdr_size+1);
+    if ((headers_file = fopen(headers_filename, "r"))==NULL)
+       {fprintf(stderr,"error opening file %s for reading - error = %d (%s)\n",headers_filename,errno,strerror(errno)); return -1;}
+    // put data into memory buffer
+    if (fread (b_headers+1,   hdr_size, 1, headers_file)<1) return -7;
+    hdr_size +=1;
+    fclose(headers_file);
+	
+return 0;    
+}
+
+static void
+main_loop(struct rtp* session) 
+{
+	uint64_t        time_frame = 0;
+	uint32_t	rtp_ts,len=0;
+	int		delta, nframe;
+	char		headers_filename[]="/tmp/headers";
+	char       	controlfn[]="/dev/ccam_img";
+
+	int 		devfd, i;
+	int 		acq_data, nframes_total, nframes_inter_full,
+			nframes_inter_masked, time_slow;
+	u_int8_t   	*ccam_dma, *dp = NULL;
+    	u_int32_t  	*ccam_dma_index;
+    	int        	circindex_fd;
+   	int        	circbuf_fd;
+    	int        	circbuf_size;
+    	int       	circindex_size;
+ 
+	int		wp,wp0,frame_start = 0,frame_end,frame_type= 0,a_ready;
+	uint32_t	frame_length;
+	int		next_frame_start, frame_no =0,last_page_flags = 0;
+
+	printf("Sending to ");
+	printf("%s port %d (local SSRC = 0x%08x)\n", 
+	       rtp_get_addr(session),
+	       rtp_get_rx_port(session),
+	       rtp_my_ssrc(session));
+
+      a_ready = 0; 
+      circindex_fd = open("/dev/circindex", O_RDWR);
+      if (circindex_fd<0) { // check control OK
+         fprintf(stderr,"Error opening %s\n", "/dev/circindex");
+         return ;
+      }
+      // find total buffer length
+      circindex_size=lseek(circindex_fd,0,2);
+      ccam_dma_index = (u_int32_t *) mmap(0, circindex_size, PROT_READ, MAP_SHARED, circindex_fd, 0);
+      if(ccam_dma_index ==((u_int32_t  *) -1)) {
+        fprintf(stderr,"Error in mmap %s\r\n","/dev/circindex");
+        close(circindex_fd);
+        return ;
+      }
+
+      circbuf_fd = open("/dev/circbuf", O_RDWR);
+      if (circbuf_fd<0) { // check control OK
+        fprintf(stderr,"Error opening %s\n", "/dev/circbuf");
+        close(circindex_fd);
+        return ;
+      }
+      // find total buffer length
+      circbuf_size=lseek(circbuf_fd,0,2);
+      fprintf(stderr,"circbuf stores %d long values (%d bytes)\n",(circbuf_size>>2),circbuf_size);
+      ccam_dma = (u_int8_t *) mmap(0, circbuf_size, PROT_READ, MAP_SHARED, circbuf_fd, 0);
+      if(ccam_dma ==((u_int8_t  *) -1)) {
+        fprintf(stderr,"Error in mmap %s\r\n","/dev/circbuf");
+        close(circindex_fd);
+        close(circbuf_fd);
+        return ;
+      }
+ 
+    
+	InitTimer();
+	wp=wp0=0;
+	
+   	nframe = HDR_INTERVAL;
+	nframes_total = 0;	// unlimited 
+	nframes_inter_full = 128;
+	nframes_inter_masked = 0;
+	time_slow = (int)(100./strm_data_par.fps);
+        fprintf(stderr,"fps =%f time_slow %d\n",strm_data_par.fps,time_slow);
+        acq_data = ((nframes_total)<<16 ) |
+                  (((nframes_inter_full   > 255)? 255:((nframes_inter_full   < 0)?0:nframes_inter_full  )) << 8) |
+                   ((nframes_inter_masked > 255)? 255:((nframes_inter_masked < 0)?0:nframes_inter_masked));
+
+
+	if(setup_tbl_FPGA( nframes_total, nframes_inter_full,
+ 				nframes_inter_masked, time_slow)<0) return;
+ 
+   	if(make_OggTheoraHdrs(headers_filename)<0) {
+		fprintf(stderr,"Error prepare headers while parsing %s\n",headers_filename);
+		free(b_headers);
+		return;
+	}
+	frame_no = 0;
+
+	while (true) {
+
+	// now - time to start acquisition
+    	if ((devfd = open(controlfn, O_RDONLY)) <0) {
+        	fprintf(stderr,"error opening file %s for reading - error = %d (%s)\n",controlfn,errno,strerror(errno)); 
+		return ;
+	}
+	// start compression
+      	ioctl(devfd, _IO(CMOSCAM_IOCTYPE, IO_CCAM_JPEG_GET_N ), acq_data);
+
+	//    now wait for done (or aborted?)
+    	while (((i=ioctl(devfd, _IO(CMOSCAM_IOCTYPE, IO_CCAM_MONITOR_SEQ ), 0))) > CAMSEQ_JPEG) {
+
+	     if(strm_data->status == STOP_STREAM ) {
+			break;   // receive command STOP from web interface
+	     }
+	// data ready ?    
+	if(wp == 0) {
+        while(frame_no <0)
+ 	 frame_no = ioctl(devfd, _CCCMD( CCAM_RPARS , P_JPEG_WP), 0)-1;
+         usec_sleep(mTimeinterval>>1);
+	 sched_yield();
+	 wp=1;
+	}
+
+dark_loop:
+
+        last_page_flags= (ccam_dma_index[frame_no+1]==0xffffffff)?4:0;
+
+	if (last_page_flags == 4)
+	{
+            usec_sleep(mTimeinterval);
+	    sched_yield();
+	    goto dark_loop;    
+	}
+//	 frame_no = ioctl(devfd, _CCCMD( CCAM_RPARS , P_JPEG_WP), 0)-1;
+
+		// soft correction FPS    
+		if(time_frame == 0) time_frame=GetTimestamp()+1; // when starting - send headers to clients
+			// check number of sended data frames
+			// may be we are ready to send Theora Headers?
+		if(nframe >= HDR_INTERVAL) {
+			rtp_SendTheoraHdrs(session,TimestampToRtp(GetTimestamp()),
+				           b_headers , hdr_size);
+				nframe = 0;
+		}
+   		delta=time_frame-GetTimestamp(); // may be waiting more ?
+  
+   		if( delta  > 0) {
+   	   		while(delta > 0){
+       				if(delta <= 10000) 
+           				usec_sleep(0); // sleeps 1 clock tick (10ms)!
+       				else
+           				usec_sleep(delta-10000);
+       				delta-=GetRelativeTime();
+     	    		}
+      		}
+        frame_length=(ccam_dma_index[frame_no] & 0xfffffff)-frame_start;
+ //       printf("FFFF %u \n",(ccam_dma_index[frame_no] & 0xfffffff)- frame_start);
+        next_frame_start=((ccam_dma_index[frame_no] & 0xfffffff)+63) & (~0x1f);
+        frame_type=(ccam_dma_index[frame_no]>>28) & 3;
+	wp0 = ioctl(devfd, _CCCMD( CCAM_RPARS , P_JPEG_WP), 0)-1;
+	if(wp0 < 0) {
+		printf("frame length %d \tframe_no %d = %d \n",frame_length,frame_no,wp0);
+
+		frame_no=wp0;
+		wp = 0;
+		continue;
+	}
+
+   		rtp_ts =TimestampToRtp(time_frame);
+
+   		time_frame+= mTimeinterval; // time start for next frame INTER/INTRA
+   		/* Send control packets */
+   		rtp_send_ctrl(session, rtp_ts, NULL);
+   		rtp_update(session);
+
+
+        dp=&ccam_dma[frame_start];
+        if((unsigned)frame_length <1000000)
+ 	     rtp_SendTheoraFrame( session, rtp_ts, dp, frame_length, frame_type);
+
+        frame_start=next_frame_start;
+	frame_no++;
+	if(frame_no > wp0)
+		wp = 0;
+
+		nframe++;
+		xmemchk();
+	   }
+     if(strm_data->status == STOP_STREAM ) {
+	// stop sencor
+        system("hello -z 0");
+        printf("RTP Streamer stopped \n");
+	break;   // receive command STOP from web interface
+
+  //ioctl(devfd, _IO(CMOSCAM_IOCTYPE, IO_CCAM_JPEG ), JPEG_CMD_STOP);
+	} // if STOP_STREAM	     
+
+   } // while main	
+
+//=========================== END MAIN LOOP ============================ 
+   
+}
+
+
+int main(int argc, char *argv[]) 
+{
+	struct rtp	*session = NULL;
+ 	int 		devfd,c,flag,use_web;
+
+    flag = 0;
+    use_web = false;
+    strcpy(strm_data_par.address,"239.0.0.1");
+    strm_data_par.port = 20000;
+    strm_data_par.fps  = 25.;
+    strm_data_par.status   = STOP_STREAM;
+//    strm_data_par.regim    = JPEG_ACCESS_DRV; 
+//    strm_data_par.scanning = STOP_SCANNING;
+    strcpy(strm_data_par.name,"Elphel Camera #1");
+    strcpy(strm_data_par.telephone,"1-800-RTP-HOT-PHONE");
+    strcpy(strm_data_par.toolname,"Elphel Theora Streamer");
+    strcpy(strm_data_par.note,"Draft release ofr RTP Theora");
+    strcpy(strm_data_par.location,"This camera located anywhere");
+    strcpy(strm_data_par.email,"camera at elphel.com");
+    strm_data_par.encrypt_key[0]='\0';
+
+   while(true) {
+     c = getopt(argc, argv, "hwa:p:f:k:");
+     if (c == -1)
+	       break;
+     
+     switch (c) {
+      	case 'h':
+	    flag++;	
+            break;
+	case 'w':
+	    use_web = true; 	
+            break;
+      	case 'a':
+	    memset(strm_data_par.address,0,21);
+	    strncpy(strm_data_par.address,optarg,20);
+            break;
+      	case 'k':
+	    memset(strm_data_par.encrypt_key,0,41);
+	    strncpy(strm_data_par.encrypt_key,optarg,40);
+	    strm_data_par.encryption=1;
+            break;
+      	case 'p':
+	    strm_data_par.port = atol(optarg);	
+            break;
+       	case 'f':
+	    strm_data_par.fps = atof(optarg);
+            if(strm_data_par.fps < 0. )
+		strm_data_par.fps=25.;	
+            break;
+
+     	case '?':
+	     flag++;
+             break;
+
+     	default:
+           printf ("?? getopt returned character code 0%o ??\n", c);
+       }
+    }
+   if ((optind < argc)|| flag>0) {
+	  usage();
+	  exit(1);
+   }
+
+   if(use_web) {
+        unlink(mmapFileName);
+	// map shared memory for manage this with CGI 
+	// where shared memory opening whith query too
+	
+        devfd = open(mmapFileName,O_RDWR|O_CREAT); 
+        if(devfd == -1) {
+  	       printf("Error opening %s!\n",mmapFileName);	  
+	       
+        }
+	lseek(devfd,sizeof(strm_data_t),SEEK_SET);
+	write(devfd,"",1);
+
+        strm_data =(strm_data_t *) mmap(0, sizeof(strm_data_t), PROT_READ|PROT_WRITE, MAP_SHARED, devfd, 0);
+        if((int)strm_data == -1) {
+             fprintf(stderr,"Error in mmap %s\r\n",mmapFileName);
+	     close(devfd);
+	     unlink(mmapFileName);
+	     exit(1);
+        }
+    } 
+    else {
+	strm_data = &strm_data_par;  // use data from local buffer   
+	// not used web - start streamer immediate
+	strm_data_par.status = START_STREAM;
+    }   	
+	
+       	// OK - init data
+
+       // General LOOP waiting command START
+	while(true) {
+	     if(strm_data->status == -1)
+		break;
+	     if(strm_data->status == STOP_STREAM ) {
+		  //sleep some time and test status again
+		  usec_sleep(100000);
+		  continue;
+	     }
+	printf("\n RTP Streamer for Theora starting...\n");
+
+	mTimeinterval = (int) TimestampTicks/strm_data->fps; // min interval between frames
+        printf("Time frame %u for FPS %f, dest address %s:%d \n\n", mTimeinterval, strm_data->fps, 
+			strm_data->address,strm_data->port);
+	memcpy((void *)&strm_data_par,(void *)strm_data,sizeof(strm_data_t));
+	//OK - receive command START streaming    
+	// create session and transmit data	
+	// address,port and fps(soft - not hardware) may be changed
+	// from web interfase
+        session = rtp_init_xmitter( strm_data->address,	/* Host/Group IP address */ 
+			   strm_data->port,		/* receive port */
+			   strm_data->port,		/* transmit port */
+			   16,			/* time-to-live */
+			   8000000,		/* B/W estimate */
+			   rtp_event_handler,	/* RTP event callback */
+			   NULL);		/* App. specific data */
+
+	if (session) {
+
+             if(strm_data->encryption) {
+                if (!rtp_set_encryption_key(session,strm_data->encrypt_key))
+			printf("Can't init encryption !\n ");
+             }
+
+	     uint32_t 	my_ssrc = rtp_my_ssrc(session);
+
+		/* Set local participant info */
+		rtp_set_sdes(session, my_ssrc, RTCP_SDES_NAME,strm_data->name, strlen(strm_data->name));
+		rtp_set_sdes(session, my_ssrc, RTCP_SDES_EMAIL,strm_data->email, strlen(strm_data->email));
+		rtp_set_sdes(session, my_ssrc, RTCP_SDES_PHONE,strm_data->telephone, strlen(strm_data->telephone));
+		rtp_set_sdes(session, my_ssrc, RTCP_SDES_LOC,strm_data->location, strlen(strm_data->location));
+		rtp_set_sdes(session, my_ssrc, RTCP_SDES_TOOL,strm_data->toolname, strlen(strm_data->toolname));
+		rtp_set_sdes(session, my_ssrc, RTCP_SDES_NOTE,strm_data->note, strlen(strm_data->note));
+
+		/* Filter out local packets if requested */
+		rtp_set_option(session, RTP_OPT_FILTER_MY_PACKETS, true );
+		rtp_set_option(session, RTP_OPT_WEAK_VALIDATION, false);
+		rtp_set_option(session, RTP_OPT_PROMISC, true);
+
+		// Run main loop - get data from buffer and sent RTP packets
+		// while this process not received command stop
+		main_loop(session);
+
+		/* Say bye-bye */
+		rtp_send_bye(session);
+		rtp_done(session);
+		xmemchk();
+	} 
+	else {
+	   fprintf(stderr,"Could not initialize session for %s port %d\n", strm_data->address, strm_data->port);
+	}
+     } // general while	
+  return 0;
+}

Added: experimental/j/Elphel333/rtp/daemon/rtp/.target-makefrag
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/.target-makefrag	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/.target-makefrag	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1 @@
+AXIS_BUILDTYPE=cris-axis-linux-gnu

Added: experimental/j/Elphel333/rtp/daemon/rtp/COPYRIGHT
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/COPYRIGHT	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/COPYRIGHT	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,35 @@
+Copyright (C) 1995-2000 University College London
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, is permitted provided that the following conditions 
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+3. All advertising materials mentioning features or use of this software
+   must display the following acknowledgement:
+     This product includes software developed by the Computer Science
+     Department at University College London
+4. Neither the name of the University nor of the Department may be used
+   to endorse or promote products derived from this software without
+   specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND ANY
+EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGE.
+
+This product includes software developed by the Computer Systems
+Engineering Group at Lawrence Berkeley Laboratory.
+
+Encryption features of this software use the RSA Data Security, Inc. MD5
+Message-Digest Algorithm.

Added: experimental/j/Elphel333/rtp/daemon/rtp/MODS
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/MODS	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/MODS	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,388 @@
+Common Code Library: Modification history
+
+v1.0.0  - Initial version, based on RAT v3.2.7
+	* 14 November 1998
+
+v1.0.1  - Added HMAC authentication code
+	- Added timeout to udp_recv()
+	- Added authentication of Mbus messages
+	- Added RTP library
+	- Added select and fd_set functions to net_udp.[ch]
+	- IPv6 code now runs on the pre-release stack for Solaris 2.7
+	- Mbus code support a configuration file on Unix, and the registry
+	  on Win32, to save/restore settings
+	- Add udp_host_addr() to get a text-version of the address to which
+	  a socket is bound.
+	- Set IPv6 ttl and loopback state correctly on Solaris
+	- Move mbus hearbeat code into this library
+	- Remove key expiry from the mbus code, since it created race
+	  conditions when multiple tools for a single conference were
+	  started either side of the expiry time.
+	- Update mbus addressing scheme - names are now sets of tokens, if the
+	  set of tokens in the destination address is a subset of the address 
+	  of the entity receiving that message then the message is accepted. An
+	  empty set is a valid destination address for a message, and that will
+	  be accepted by all receivers (ie: a wildcard).
+	- Remove channel ID from mbus code.
+	- Fix configure script to work with solaris 2.7 where inet_aton() and 
+	  inet_pton() have prototypes but no implementation.
+	* 31 March 1999 [rat v4.0.0]
+
+v1.0.2  - Assorted fixes to RTP library
+	- Fix bounds overruns in memory.c - will now run with -DDEBUG_MEM
+	  with the bounds checker on.
+	- Add timestamp to mbus packet headers.
+	- Add mbus_qmsgf()
+	- Cleanup mbus transmission path
+	- Add support for DES encryption to the mbus (on by default)
+	- Fix DES code
+	- Mbus keeps a cache of other entities, and only allows sending of
+	  reliable messages to known unicast addresses. 
+	- Mbus error function now takes a "type of error" argument
+	- Added xrealloc()
+	- Fix reordering of mbus messages
+	* 14 May 1999 [rat v4.0.1]
+
+v1.0.3  - Fix inet_aton() in net_udp.c
+	* 15 May 1999 [rat v4.0.2]
+
+v1.0.4  - Fix compilation with Microsoft IPv6 stack
+	- Solaris 2.5.1 doesn't have vsnprintf(), use vsprintf() instead
+	  and don't worry about the possible buffer overflow problems. 
+	  Reported by Holger Wirtz.
+	- Added mbus_addr_valid()
+	- Added timeout to mbus_recv()
+	- Fixes to mbus code from Dirk Kutscher
+	* 2 June 1999 [rat v4.0.3]
+
+v1.0.5  - Not quite sure what happened with this version, but if you have
+	  it it's probably not a good idea to use it! :-)
+
+v1.0.6  - Add ability to send to one port whilst receiving on another, 
+	  requested by Henning Schulzrinne.
+	- Add mbus_cmd_handler() to change the function handling the
+	  reception of mbus commands.
+	- Compilation fixes for Irix 6.5 contributed by Bob Olson.
+	- Add extra sanity checking to mbus_recv()
+	- Add extra sanity checking to mbus_parse_*
+	- Fix source address passed to mbus_recv() callback - was missing
+	  the "(" and ")" around it.
+	- Fix memory leak in mbus_recv()
+	- Fixes for configure script on 64 bit IRIX from Peter Orbaek
+	- Move base64 tests into test_base64.c and integrate with the test suite
+	* Released 5 July 1999 
+
+v1.0.7  - Add udp_exit to close sockets and leave multicast groups if necessary.
+	- Fix mbus_exit close sockets.
+	- Move the code to deal with the mbus configuration into mbus_config.c
+	  which will make it easier to write an mbus packet logger without code 
+	  duplication (such a logger can't easily be part of mbus.c, since it's
+	  needs conflict with correct protocol operation).
+	- Note that v1.3 of the Microsoft Research IPv6 stack requires an explicit
+	  route to be added for multicast traffic before a group can be joined. If
+	  you get errors in the IPV6_ADD_MEMBERSHIP setsockopt, this is probably
+	  the reason. We could specify an interface explicitly, but which one to
+	  pick?
+	- Updates to the IPv6 code for the Detexis Musica IPv6 stack
+	- Updates to the RTP code from Markus Germeier: time-out and delete sources,
+	  fix X but in RTP header, add support for sending BYE packets.
+	- Add inet_pton() and inet_ntop() implementations, for those platforms
+	  which are missing them.
+	- Add gettimeofday() workaround for win32
+	- Add drand48() workaround for win32
+	* Released 20 August 1999
+
+v1.0.8  - Add mbus_sent_all()
+	- Add loop count to mbus_recv(), so it will always return after 10
+	  packets have been received. The prevents a denial of service attack
+	  if packets are sent faster than the timeout period.
+	- Add binary tree.
+	- Add OpenBSD fixes from Angelos D. Keromytis
+	- Add Jerry Isdale's debug_dump() routine.
+	- Add fix to RTP init_seq() to correct bug(?) in RFC1889 which
+	  means we incorrectly report the one packet lost in the first
+	  reporting interval. Fix by Bill Fenner.
+	- Make the RTP create_source() routine return a pointer to the
+	  source. Patch from Bill Fenner.
+	- Changes to the probation code in rtp.c from Bill Fenner.
+	- Fix types in the RTP source struct.
+	- Add a SOURCE_CREATED event to the RTP callback.
+	- Add option to accept RTP packets before a corresponding RTCP
+	  packet has been received.
+	- Add RX_RR_EMPTY event to the RTP code, to indicate that an empty
+	  reception report (ie: no report blocks) has been received.
+	- Add RX_RTCP_START and RX_RTCP_FINISH events to the RTP code.
+	- debug_msg() now displays the pid
+	- The mbus code now maintains the list of active sources more correctly, 
+	  making mbus_addr_valid() useful
+	- rtp_init() now takes separate rx_port and tx_port, instead of a
+	  single port for both sending and receiving.
+	- Add rtp_get_addr(), rtp_get_rx_port(), rtp_get_tx_port() and rtp_get_ttl()
+	- Change return type of rtp_recv to int (was void).  Returns TRUE if
+	  packets were processed, FALSE otherwise.
+	- Timeout RRs from the RTP database, if they're not refreshed for
+	  3 times the RTCP reporting interval
+	- rtp_update() only expires sources once per reporting interval, to
+	  avoid burning too many cycles.
+	- Mbus updates contributed by Markus Germeier
+		- we now can configure the multicast address and port which the
+		  mbus should use in ~/.mbus 
+		- honor the SCOPE setting in ~/.mbus
+		- expire sources we haven't heard from for a while
+		- fixes small memory leak in remove_other_addr
+		- mbus_exit now sends a mbus.quit and cleans up other_* structures
+	- RTP updates contributed by Timur Friedman.
+		- Add support for RTCP APP packets
+		- Add support for a promiscuous mode to the RTP code, when in
+		  promiscuous mode there is no wait for a minimum number of RTP
+		  packets before recognizing a source.
+		- Add the functions rtp_setopt() and rtp_getopt() that can be used
+		  to control various options (right now just promiscuous mode).
+		- Split rtp_recv_data() into two functions.
+	* 5 October 1999
+
+v1.0.9  - Ignore ECONNREFUSED in net_udp.c
+	- Add mbus_rendezvous_waiting() and mbus_rendezvous_go() to enable
+	  easy rendezvous between multiple processes.
+	- Change rtp_setopt() and rtp_getopt() to take boolean options only.
+	- Remove rtp_weak_validation(), use rtp_setopt(RTP_OPT_WEAK_VALIDATION)
+	  instead.
+	- Delete RTP database entries which haven't been heard from for
+	  more than 5 times the RTCP reporting interval.
+	* 2 November 1999 [rat v4.1.1]
+
+v1.0.10 - Mbus updates from Markus Germeier, which fix compatibility with
+	  the Uni Bremen implementation:
+		- mbus.bye() signals an entity when it leaves. (mbus.quit commands
+		  an entity to leave)
+		- Generate and work with 64 bit DES keys. Generate parity bits for key.
+		  Check if key in configuration file sets parity bits correctly.
+		- mbus_heartbeat(m, 1) should send an mbus.hello() every second and
+		  not every two seconds
+		- HMAC-MD5 should read HMAC-MD5-96
+		- Honor the MBUS environment variable for the MBUS configuration file
+		- The TZI Mbus implementations generate spaces in configuration file,
+		  which mislead the UCL Mbus to dump core. Allow Spaces in .mbus
+		- Address must be unique
+		- Delete failed reliable messages if err_handler is present
+	- Fix uninitialized use of session->last_update in RTP code
+	- Fix assertion failures in RTP library when sending RTCP packets
+	- Recognize, but ignore, profile specific extensions to RTCP SR/RR packets
+	- Update RTCP reporting interval calculation
+	- Implement reverse reconsideration of RTCP reporting interval
+	- Fix tv_diff in rtp.c to handle negative results
+	- Remove rtp_get_encryption_key(), the user of the library is assumed to 
+	  remember the passphrase used and doesn't need access to the internal
+	  form of the key.
+	- GNU autoconf modifications from Bill Fenner
+	- Global change of integer types, and removal of compatibility defines:
+		u_int8  -> u_int8_t
+		u_int16 -> u_int16_t
+		u_int32 -> u_int32_t
+	  and the same for the signed varients.
+	- Implement encryption in the RTP code
+	- Ignore connection refused errors in IPv4 UDP send.
+	- Hide definition of struct mbus_config
+	- Add a version number to the mbus config file
+	- Fixes for FreeBSD v3.2 with INRIA IPv6 stack from Fred Templin
+	- Add configure check for sin6_len in struct sockaddr_in6 (seems
+	  that FreeBSD has this, but many systems don't)
+	- Fix batching of multiple mbus messages into one packet.
+	* 13 December 1999 [rat v4.1.2]
+
+v1.1.0  - Changed autoconf generated header to uclconf.h.
+	- Changed library name to uclmmbase to be consistent with other libs.   
+	- Add RTP_OPT_FILTER_MY_PACKETS
+	- Cleanup test routines
+	- Fix various potential buffer overflow problems
+	- Update copyright notices to welcome in the new millennium
+	- Previous versions of udp_send() would sometimes return -1 on error, 
+	  and would sometimes abort(). We now always return -1 and never abort.
+	- Add test routines for code in net_udp.c
+	- Fix SCOPE parameter in mbus configuration on windows
+	- Fix sending of hearbeat messages whilst in mbus.waiting() and mbus.go() loops
+	- Tidy up mbus_qmsg();
+	- Add workaround for buffer overflow bug in _dprintf() which caused
+	  a crash under Windows NT service pack 6. This is not a real fix, we
+	  need to use vsnprintf() in there, but Windows doesn't implement it
+	  and I don't have time before we give the demo... Sigh, only two
+	  days wasted.
+	- Fix buffer overflow in _dprintf() on Windows, using _vsnprintf().
+	- Update IPv6 support for Microsoft Research IPv6 stack, v1.4
+		- Use the versions of inet_ntop() and inet_pton() provided with the 
+		  IPv6 stack, but retain our own implementation when building with 
+		  IPv4 support only.
+		- Use getaddrinfo() rather than getnodebyname() to get our IPv6 address if
+		  running with the Microsoft Research IPv6 stack. 
+		- We now require getaddrinfo() to be present in all IPv6 stacks: those which
+		  do not have this call (eg: the Musica IPv6 stack) MUST provide a workaround
+		  implementation.
+	  versions of MSR IPv6 prior to 1.4 are no longer supported.
+	- Update IPv6 support for Red Hat Linux 6.1
+	- Fix generation of version.h on Win32
+	- Add VC++ project file to build the test suite under Win32
+	- Add extra debug code to the mbus library
+	- Rewrite mbus code: mbus_parser.[ch] exist now, and include routines moved from the
+	  main mbus.[ch] files. Note that the interface to the mbus_parse_*() functions has
+	  now changed and is not backwards compatible.
+	- Remove the mbus_addr() function, add an extra parameter to mbus_init() instead.
+	* 28 January 2000
+
+v1.1.1  - Add extra debugging code
+	* 1 February 2000
+
+v1.1.2  - Add routines for handling NTP format timestamps, in ntp.[ch]
+	- Add udp_addr_valid.
+	- Fix cname setup for Win32.
+	- Add udp_init_if() call, to open a UDP/IP socket bound to a
+	  specific interface
+	- Add rtp_init_if() call, to open an RTP socket bound to a 
+	  specific interface
+	- Add asarray.[ch] string holding associative array.
+	- Fix compilation with -Wwrite-strings and -Wcast-align
+	- Split mbus_addr_match() and mbus_add_identical() into mbus_addr.[ch]
+	* 14 February 2000
+
+v1.1.3  - Fix debug_set_core_dir() when not debugging.
+	* 14 February 2000
+
+v1.1.4  - Add tests for mbus_parser.c/mbus_addr.c and fix bugs found
+	- Fix use of free()'d memory in mbus.c
+	* 24 February 2000
+
+v1.1.5  - Remove SunOS and Solaris defines from the configure script, they
+	  shouldn't be necessary any longer.
+	- Add workaround for missing getaddrinfo() on some platforms.
+	- Remove most of the abort() statements from udp_init(), we now
+	  return NULL in most cases of an error.
+	- Fix header extension handling when padding bit set for RTP packets.
+	- Change RTP event type #defines into rtp_event_type so compiler can
+	  check all cases are covered in decision blocks.
+	- Fix waiting_ack next is set to null when message is put on ack list.
+	- Add check for udp socket allocation success in mbus_init.
+	- Add get_appname to util.[ch].
+	- Bound ttl to max 127 in rtp.c rather than asserting <= 127.
+	- Change rtp_init to return NULL in rtp.c if ports or ttl 
+	  inappropriate.
+	- Clarify that rtp_recv(), rtp_send_data() and rtp_send_ctrl() take an
+	  RTP format timestamp for the current time.
+	* 17 April 2000
+
+v1.2.0	- Add udp_fd() function, to retrieve the underlying file descriptor.
+	- udp_get_host_addr4() will now return NULL on failure, and leave
+	  errno set.
+	- Workaround failure to get host IP address when setting the RTP
+	  CNAME (we use user at 127.0.0.1 as the CNAME in this case). 
+	- Fix rtp_send_data() to correctly handle header extensions. This required
+	  a change to the API: the extn_len parameter now counts the length on the
+	  extension in 32 bit words minus one, and there is an additional extn_type
+	  parameter. If you don't use header extensions in your application, set the
+	  additional parameter to zero. 
+	- Fix reception of packets with RTP header extension.
+	* 16 May 2000
+
+v1.2.1	* 16 June 2000 [rat v4.2.5]
+
+v1.2.2	- Fix bug in mbus transmit code which caused messages to have the same sequence
+	  number as the preceeding ack.
+	- Remove get_appname() function from util.[ch], since it didn't
+	  work in all cases (sometimes argv[0] doesn't contain anything
+	  sensible).
+	- Fix RTP header extension code (patch from Jori <jori at lumumba.luc.ac.be>)
+	  as part of RTP interoperability tests.
+	- FreeBSD 4.1 doesn't support binding to an IPv6 multicast address, must
+	  bind to in6addr_any instead (reported by Shirasaki Yasuhiro).
+	- Fix validation of RTCP packets with padding (reported by Vladimir Brauner).
+	- Fix padding octet count in RTCP packets sent with padding (Vladimir Brauner).
+	- Fix RTCP timer reconsideration (Vladimir Brauner).
+	* 22 August 2000 [rat v4.2.8]
+
+v1.2.3	- Add prototype for rtp_del_csrc() which will be needed by the
+ 	  mixer in rat.
+	* 8 September 2000 [rat v4.2.9]
+
+v1.2.4	- Implement rtp_add_csrc() and rtp_del_csrc().
+	- ifdef'ed out FreeBSD bug check in test_net_udp.c for Win32.  
+	  Prevents compilation of test cases otherwise.  Reported by Micheal
+	  Stovenour <michael.stovenour at lucent.com>.
+	* 1 November 2000 [rat v4.2.10]
+
+v1.2.5	- More informative error message when the lock on the mbus configuration 
+	  file cannot be gained.
+	- rtp_init()/rtp_init_if() now take "const char *" for the address
+	- Fix expiration of our own SSRC from the RTP database, if filtering our
+	  packets.
+	- Mark entries in the RTP source database as active senders if we can an 
+	  SR packet from them.
+	- Cleanup RTP database once per second, rather than once per reporting 
+	  interval. This is needed to ensure that reverse reconsideration works
+	  correctly, and sources are correctly deleted after BYEs are received.
+	- Fix reverse reconsideration of the RTCP interval
+	- Change socket_error to support formatted messages.
+	- Add socket_error messages for gethostbyname failures.
+	- Include lower layer overhead when calculating average RTCP size
+	  (patch from Timur Friedman).
+	- Add support for SDES PRIV (the correct formatting of the PRIV item
+	  into prefix length, prefix and value is left to the caller).
+	- Change xmalloc to fill allocated buffer with dummy value when DEBUG 
+	  is defined.  Change DEBUG_MEM version to use same dummy value rather
+	  than a random value, reduces chances of uninitialized pointers 
+	  trashing data before crashing.
+	- Add callback types to rtp.h - rtp_callback and rtcp_app_callback.
+	- For consistency rtp_{get,set}opt -> rtp_{get,set}_option.
+	- Remove unnecessary components from qfdes enumeration declarations.
+	- New directories (src, tests, docs, examples).
+	- Fixed Win32 .{dsw,dsp} files for new directory structure.
+	- Documented net_udp.c.
+	- Move strfind to util.[ch] from mbus_addr.[ch].
+	- Fix CSRC handling (patch from Ivo Sedlacek <ivo.sedlacek at anfdata.cz>)
+	- Fix uninitialized field in SDES PRIV handling (Robert Olson)
+	- Documented debug.[ch], hmac.[ch], md5.[ch], memory.[ch], rtp.[ch].
+	- Added small rtp example. 
+	- Change configure to only select doc for build if gtkdoc installed.
+	* 5 April 2001 [rat v4.2.14]	
+
+1.2.6	- Fix so that we no longer send an RTCP BYE if we leave the session 
+          before sending any other packets.
+	- Fix initial estimate of average RTCP packet size.
+	- Implement RTCP BYE reconsideration.
+	- Fix RTCP transmission interval.
+	- Fix handling of probationary sources in the RTP code (a source is
+	  no longer treated as probationary if we've received RTCP packet 
+	  from it).
+	* 24 April 2001 [rat v4.2.16]
+
+1.2.7	- Add support for Rijndael encryption to the RTP library, contributed
+          by Robert Olson <olson at mcs.anl.gov>.
+	- Fix IPv6 support on Linux
+	- Add configuration for Windows 2000 IPv6 stack
+	- Connect/disconnect to socket before/after getsockname call to make 
+	  it work
+	* 18 May 2001 [rat v4.2.17]
+
+1.2.8   - Created a new socket for use for getsockname - there were too
+          many bugs with disconnecting an IPv6 connected socket.
+    - Fixed include ordering for Win2k.
+    * 25 May 2001 [rat v4.2.18] [nte v2.2]
+
+
+Still to do...
+	- IPv6 code sometimes doesn't get the correct interface address,
+	  since it does a gethostbyname() and looks that up, yet that can
+	  return the IPv4 hostname only on some machines.
+	- Doesn't do DNS AAAA lookups when given a name rather than an IP address.
+	- Mbus code should check timestamp in received headers, and discard
+	  messages if it decreases, as a hinderance to replay attacks.
+	- Mbus code should be more paranoid about handling garbage inputs, we
+	  can likely get all sorts of buffer overflows by feeding random data
+	  into it.
+	- rtp_recv should split into rtp_select and rtp_recv. Jitter issues
+	  otherwise, as pointed out by Orion.
+	- Allow a callback for background processing during mbus_rendezvous_*()
+	- mbus_exit() queues an mbus.bye() message, but that never gets sent.
+	- Handling of SSRC collisions is broken.
+	- When weak RTP validation is enabled, spurious sources can be
+	  added to the database (from the CSRC area of a packet?). Reported
+	  by Xiaotao Wu <xiaotaow at cs.columbia.edu>
+	- RTP estimate of lower layer overhead is IPv4 specific.
+

Added: experimental/j/Elphel333/rtp/daemon/rtp/Makefile.am
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/Makefile.am	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/Makefile.am	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,101 @@
+SUBDIRS = win32
+
+noinst_LTLIBRARIES = libuclmmbase.la
+
+
+libuclmmbase_la_SOURCES= \
+	asarray.c \
+	base64.c \
+	btree.c \
+	crypt_random.c \
+	debug.c \
+	drand48.c \
+	hmac.c \
+	inet_ntop.c \
+	inet_pton.c \
+	mbus.c \
+	mbus_addr.c \
+	mbus_config.c \
+	mbus_parser.c \
+	md5.c \
+	memory.c \
+	net_udp.c \
+	ntp.c \
+	qfDES.c \
+	rijndael-alg-fst.c \
+	rijndael-api-fst.c \
+	rtp.c \
+	util.c \
+	version.h 
+
+EXTRA_DIST = \
+	acconfig.h \
+	addrinfo.h \
+	addrsize.h \
+	asarray.h \
+	base64.h \
+	bills_srtp.h \
+	bittypes.h \
+	boxes-fst.dat \
+	btree.h \
+	cdecl_ext.h \
+	common60.dsp \
+	config_unix.h \
+	config_win32.h \
+	COPYRIGHT \
+	crypt_random.h \
+	debug.h \
+	drand48.h \
+	getaddrinfo.c \
+	gettimeofday.c \
+	gettimeofday.h \
+	hmac.h \
+	inet_ntop.h \
+	inet_pton.h \
+	install-sh \
+	mbus_addr.h \
+	mbus_config.h \
+	mbus.h \
+	mbus_parser.h \
+	md5.h \
+	memory.h \
+	net_udp.h \
+	ntp.h \
+	qfDES.h \
+	rijndael-alg-fst.h \
+	rijndael-api-fst.h \
+	rtp.h \
+	sockstorage.h \
+	util.h \
+	vsnprintf.c \
+	vsnprintf.h \
+	MODS \
+	README \
+	README.qfdes \
+	VERSION \
+	test_rtp_encrypt.txt \
+	test-libcommon
+
+check_PROGRAMS = test
+test_SOURCES = \
+	test.c \
+	test_base64.c \
+	test_base64.h \
+	test_des.c \
+	test_des.h \
+	test_mbus_addr.c \
+	test_mbus_addr.h \
+	test_mbus_parser.c \
+	test_mbus_parser.h \
+	test_md5.c \
+	test_md5.h \
+	test_memory.c \
+	test_memory.h \
+	test_net_udp.c \
+	test_net_udp.h 
+
+test_LDADD = libuclmmbase.la
+version.h: VERSION
+	sed -e 's/.*/#define CCL_VERSION "v&"/' $? > version.h
+
+AM_CFLAGS = -DDEBUG

Added: experimental/j/Elphel333/rtp/daemon/rtp/Makefile.in
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/Makefile.in	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/Makefile.in	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,786 @@
+# Makefile.in generated by automake 1.7.2 from Makefile.am.
+# @configure_input@
+
+# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
+# Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+AXIS_USABLE_LIBS = GLIBC UCLIBC
+include $(AXIS_TOP_DIR)/tools/build/Rules.axis
+
+ at SET_MAKE@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+top_builddir = .
+
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+INSTALL = @INSTALL@
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+host_triplet = @host@
+ACLOCAL = @ACLOCAL@
+AMDEP_FALSE = @AMDEP_FALSE@
+AMDEP_TRUE = @AMDEP_TRUE@
+AMTAR = @AMTAR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+##CC = @CC@
+##CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+##CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+GTKDOC = @GTKDOC@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+OBJEXT = @OBJEXT@
+OPTDOC = @OPTDOC@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+RANLIB = cris-ranlib 
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+##STRIP = @STRIP@
+VERSION = @VERSION@
+##ac_ct_CC = @ac_ct_CC@
+##ac_ct_RANLIB = @ac_ct_RANLIB@
+##ac_ct_STRIP = @ac_ct_STRIP@
+am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
+am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
+am__include = @am__include@
+am__quote = @am__quote@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+datadir = @datadir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+oldincludedir = @oldincludedir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+SUBDIRS = win32
+
+noinst_LTLIBRARIES = libuclmmbase.la
+
+libuclmmbase_la_SOURCES = \
+	asarray.c \
+	base64.c \
+	btree.c \
+	crypt_random.c \
+	debug.c \
+	drand48.c \
+	hmac.c \
+	inet_ntop.c \
+	inet_pton.c \
+	mbus.c \
+	mbus_addr.c \
+	mbus_config.c \
+	mbus_parser.c \
+	md5.c \
+	memory.c \
+	net_udp.c \
+	ntp.c \
+	qfDES.c \
+	rijndael-alg-fst.c \
+	rijndael-api-fst.c \
+	rtp.c \
+	util.c \
+	version.h 
+
+
+EXTRA_DIST = \
+	acconfig.h \
+	addrinfo.h \
+	addrsize.h \
+	asarray.h \
+	base64.h \
+	bills_srtp.h \
+	bittypes.h \
+	boxes-fst.dat \
+	btree.h \
+	cdecl_ext.h \
+	common60.dsp \
+	config_unix.h \
+	config_win32.h \
+	COPYRIGHT \
+	crypt_random.h \
+	debug.h \
+	drand48.h \
+	getaddrinfo.c \
+	gettimeofday.c \
+	gettimeofday.h \
+	hmac.h \
+	inet_ntop.h \
+	inet_pton.h \
+	install-sh \
+	mbus_addr.h \
+	mbus_config.h \
+	mbus.h \
+	mbus_parser.h \
+	md5.h \
+	memory.h \
+	net_udp.h \
+	ntp.h \
+	qfDES.h \
+	rijndael-alg-fst.h \
+	rijndael-api-fst.h \
+	rtp.h \
+	sockstorage.h \
+	util.h \
+	vsnprintf.c \
+	vsnprintf.h \
+	MODS \
+	README \
+	README.qfdes \
+	VERSION \
+	test_rtp_encrypt.txt \
+	test-libcommon
+
+
+check_PROGRAMS = test
+test_SOURCES = \
+	test.c \
+	test_base64.c \
+	test_base64.h \
+	test_des.c \
+	test_des.h \
+	test_mbus_addr.c \
+	test_mbus_addr.h \
+	test_mbus_parser.c \
+	test_mbus_parser.h \
+	test_md5.c \
+	test_md5.h \
+	test_memory.c \
+	test_memory.h \
+	test_net_udp.c \
+	test_net_udp.h 
+
+
+test_LDADD = libuclmmbase.la
+
+AM_CFLAGS = -DDEBUG
+subdir = .
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = uclconf.h
+CONFIG_CLEAN_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+
+libuclmmbase_la_LDFLAGS =
+libuclmmbase_la_LIBADD =
+am_libuclmmbase_la_OBJECTS = asarray.lo base64.lo btree.lo \
+	crypt_random.lo debug.lo drand48.lo hmac.lo inet_ntop.lo \
+	inet_pton.lo mbus.lo mbus_addr.lo mbus_config.lo mbus_parser.lo \
+	md5.lo memory.lo net_udp.lo ntp.lo qfDES.lo rijndael-alg-fst.lo \
+	rijndael-api-fst.lo rtp.lo util.lo
+libuclmmbase_la_OBJECTS = $(am_libuclmmbase_la_OBJECTS)
+check_PROGRAMS = test$(EXEEXT)
+am_test_OBJECTS = test.$(OBJEXT) test_base64.$(OBJEXT) \
+	test_des.$(OBJEXT) test_mbus_addr.$(OBJEXT) \
+	test_mbus_parser.$(OBJEXT) test_md5.$(OBJEXT) \
+	test_memory.$(OBJEXT) test_net_udp.$(OBJEXT)
+test_OBJECTS = $(am_test_OBJECTS)
+test_DEPENDENCIES = libuclmmbase.la
+test_LDFLAGS =
+
+DEFAULT_INCLUDES =  -I. -I$(srcdir) -I.
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+ at AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/asarray.Plo ./$(DEPDIR)/base64.Plo \
+ at AMDEP_TRUE@	./$(DEPDIR)/btree.Plo ./$(DEPDIR)/crypt_random.Plo \
+ at AMDEP_TRUE@	./$(DEPDIR)/debug.Plo ./$(DEPDIR)/drand48.Plo \
+ at AMDEP_TRUE@	./$(DEPDIR)/hmac.Plo ./$(DEPDIR)/inet_ntop.Plo \
+ at AMDEP_TRUE@	./$(DEPDIR)/inet_pton.Plo ./$(DEPDIR)/mbus.Plo \
+ at AMDEP_TRUE@	./$(DEPDIR)/mbus_addr.Plo \
+ at AMDEP_TRUE@	./$(DEPDIR)/mbus_config.Plo \
+ at AMDEP_TRUE@	./$(DEPDIR)/mbus_parser.Plo ./$(DEPDIR)/md5.Plo \
+ at AMDEP_TRUE@	./$(DEPDIR)/memory.Plo ./$(DEPDIR)/net_udp.Plo \
+ at AMDEP_TRUE@	./$(DEPDIR)/ntp.Plo ./$(DEPDIR)/qfDES.Plo \
+ at AMDEP_TRUE@	./$(DEPDIR)/rijndael-alg-fst.Plo \
+ at AMDEP_TRUE@	./$(DEPDIR)/rijndael-api-fst.Plo \
+ at AMDEP_TRUE@	./$(DEPDIR)/rtp.Plo ./$(DEPDIR)/test.Po \
+ at AMDEP_TRUE@	./$(DEPDIR)/test_base64.Po ./$(DEPDIR)/test_des.Po \
+ at AMDEP_TRUE@	./$(DEPDIR)/test_mbus_addr.Po \
+ at AMDEP_TRUE@	./$(DEPDIR)/test_mbus_parser.Po \
+ at AMDEP_TRUE@	./$(DEPDIR)/test_md5.Po ./$(DEPDIR)/test_memory.Po \
+ at AMDEP_TRUE@	./$(DEPDIR)/test_net_udp.Po ./$(DEPDIR)/util.Plo
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \
+	$(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(AM_LDFLAGS) $(LDFLAGS) -o $@
+DIST_SOURCES = $(libuclmmbase_la_SOURCES) $(test_SOURCES)
+
+RECURSIVE_TARGETS = info-recursive dvi-recursive pdf-recursive \
+	ps-recursive install-info-recursive uninstall-info-recursive \
+	all-recursive install-data-recursive install-exec-recursive \
+	installdirs-recursive install-recursive uninstall-recursive \
+	check-recursive installcheck-recursive
+DIST_COMMON = README Makefile.am Makefile.in acconfig.h aclocal.m4 \
+	config.guess config.h.in config.sub configure configure.in \
+	depcomp install-sh ltmain.sh missing mkinstalldirs
+DIST_SUBDIRS = $(SUBDIRS)
+SOURCES = $(libuclmmbase_la_SOURCES) $(test_SOURCES)
+
+all: uclconf.h
+	$(MAKE) $(AM_MAKEFLAGS) all-recursive
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+
+am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
+ configure.lineno
+$(srcdir)/Makefile.in:  Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign  Makefile
+Makefile:  $(srcdir)/Makefile.in  $(top_builddir)/config.status
+	cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)
+
+$(top_builddir)/config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	$(SHELL) ./config.status --recheck
+$(srcdir)/configure:  $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
+	cd $(srcdir) && $(AUTOCONF)
+
+$(ACLOCAL_M4):  configure.in 
+	cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
+
+uclconf.h: stamp-h1
+	@if test ! -f $@; then \
+	  rm -f stamp-h1; \
+	  $(MAKE) stamp-h1; \
+	else :; fi
+
+stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
+	@rm -f stamp-h1
+	cd $(top_builddir) && $(SHELL) ./config.status uclconf.h
+
+$(srcdir)/config.h.in:  $(top_srcdir)/configure.in $(ACLOCAL_M4) $(top_srcdir)/acconfig.h
+	cd $(top_srcdir) && $(AUTOHEADER)
+	touch $(srcdir)/config.h.in
+
+distclean-hdr:
+	-rm -f uclconf.h stamp-h1
+
+clean-noinstLTLIBRARIES:
+	-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+	@list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" = "$$p" && dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+libuclmmbase.la: $(libuclmmbase_la_OBJECTS) $(libuclmmbase_la_DEPENDENCIES) 
+	$(LINK)  $(libuclmmbase_la_LDFLAGS) $(libuclmmbase_la_OBJECTS) $(libuclmmbase_la_LIBADD) $(LIBS)
+	cd .libs && ln -s libuclmmbase.al libuclmmbase.a
+
+clean-checkPROGRAMS:
+	@list='$(check_PROGRAMS)'; for p in $$list; do \
+	  f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+	  echo " rm -f $$p $$f"; \
+	  rm -f $$p $$f ; \
+	done
+test$(EXEEXT): $(test_OBJECTS) $(test_DEPENDENCIES) 
+	@rm -f test$(EXEEXT)
+	$(LINK) $(test_LDFLAGS) $(test_OBJECTS) $(test_LDADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT) core *.core
+
+distclean-compile:
+	-rm -f *.tab.c
+
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/asarray.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/base64.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/btree.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/crypt_random.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/debug.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/drand48.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/hmac.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/inet_ntop.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/inet_pton.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/mbus.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/mbus_addr.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/mbus_config.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/mbus_parser.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/md5.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/memory.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/net_udp.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ntp.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/qfDES.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/rijndael-alg-fst.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/rijndael-api-fst.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/rtp.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_base64.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_des.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_mbus_addr.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_mbus_parser.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_md5.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_memory.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_net_udp.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/util.Plo at am__quote@
+
+distclean-depend:
+	-rm -rf ./$(DEPDIR)
+
+.c.o:
+ at am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
+ at am__fastdepCC_TRUE@	  -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \
+ at am__fastdepCC_TRUE@	then mv "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
+ at am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
+ at am__fastdepCC_TRUE@	fi
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$<
+
+.c.obj:
+ at am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
+ at am__fastdepCC_TRUE@	  -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`; \
+ at am__fastdepCC_TRUE@	then mv "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
+ at am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
+ at am__fastdepCC_TRUE@	fi
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(COMPILE) -c `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`
+
+.c.lo:
+ at am__fastdepCC_TRUE@	if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
+ at am__fastdepCC_TRUE@	  -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \
+ at am__fastdepCC_TRUE@	then mv "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; \
+ at am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
+ at am__fastdepCC_TRUE@	fi
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+distclean-libtool:
+	-rm -f libtool
+uninstall-info-am:
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run `make' without going through this Makefile.
+# To change the values of `make' variables: instead of editing Makefiles,
+# (1) if the variable is set in `config.status', edit `config.status'
+#     (which will cause the Makefiles to be regenerated when you run `make');
+# (2) otherwise, pass the desired values on the `make' command line.
+$(RECURSIVE_TARGETS):
+	@set fnord $$MAKEFLAGS; amf=$$2; \
+	dot_seen=no; \
+	target=`echo $@ | sed s/-recursive//`; \
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  echo "Making $$target in $$subdir"; \
+	  if test "$$subdir" = "."; then \
+	    dot_seen=yes; \
+	    local_target="$$target-am"; \
+	  else \
+	    local_target="$$target"; \
+	  fi; \
+	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+	   || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
+	done; \
+	if test "$$dot_seen" = "no"; then \
+	  $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+	fi; test -z "$$fail"
+
+mostlyclean-recursive clean-recursive distclean-recursive \
+maintainer-clean-recursive:
+	@set fnord $$MAKEFLAGS; amf=$$2; \
+	dot_seen=no; \
+	case "$@" in \
+	  distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+	  *) list='$(SUBDIRS)' ;; \
+	esac; \
+	rev=''; for subdir in $$list; do \
+	  if test "$$subdir" = "."; then :; else \
+	    rev="$$subdir $$rev"; \
+	  fi; \
+	done; \
+	rev="$$rev ."; \
+	target=`echo $@ | sed s/-recursive//`; \
+	for subdir in $$rev; do \
+	  echo "Making $$target in $$subdir"; \
+	  if test "$$subdir" = "."; then \
+	    local_target="$$target-am"; \
+	  else \
+	    local_target="$$target"; \
+	  fi; \
+	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+	   || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
+	done && test -z "$$fail"
+tags-recursive:
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+	done
+ctags-recursive:
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+	done
+
+ETAGS = etags
+ETAGSFLAGS =
+
+CTAGS = ctags
+CTAGSFLAGS =
+
+tags: TAGS
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	mkid -fID $$unique
+
+TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  if test "$$subdir" = .; then :; else \
+	    test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \
+	  fi; \
+	done; \
+	list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	test -z "$(ETAGS_ARGS)$$tags$$unique" \
+	  || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	     $$tags $$unique
+
+ctags: CTAGS
+CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+
+top_distdir = .
+distdir = $(PACKAGE)-$(VERSION)
+
+am__remove_distdir = \
+  { test ! -d $(distdir) \
+    || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \
+         && rm -fr $(distdir); }; }
+
+GZIP_ENV = --best
+distuninstallcheck_listfiles = find . -type f -print
+distcleancheck_listfiles = find . -type f -print
+
+distdir: $(DISTFILES)
+	$(am__remove_distdir)
+	mkdir $(distdir)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+	list='$(DISTFILES)'; for file in $$list; do \
+	  case $$file in \
+	    $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+	    $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+	  esac; \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+	    dir="/$$dir"; \
+	    $(mkinstalldirs) "$(distdir)$$dir"; \
+	  else \
+	    dir=''; \
+	  fi; \
+	  if test -d $$d/$$file; then \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  if test "$$subdir" = .; then :; else \
+	    test -d $(distdir)/$$subdir \
+	    || mkdir $(distdir)/$$subdir \
+	    || exit 1; \
+	    (cd $$subdir && \
+	      $(MAKE) $(AM_MAKEFLAGS) \
+	        top_distdir="$(top_distdir)" \
+	        distdir=../$(distdir)/$$subdir \
+	        distdir) \
+	      || exit 1; \
+	  fi; \
+	done
+	-find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
+	  ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
+	  ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
+	  ! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \
+	|| chmod -R a+r $(distdir)
+dist-gzip: distdir
+	$(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+	$(am__remove_distdir)
+
+dist dist-all: distdir
+	$(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+	$(am__remove_distdir)
+
+# This target untars the dist file and tries a VPATH configuration.  Then
+# it guarantees that the distribution is self-contained by making another
+# tarfile.
+distcheck: dist
+	$(am__remove_distdir)
+	GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(AMTAR) xf -
+	chmod -R a-w $(distdir); chmod a+w $(distdir)
+	mkdir $(distdir)/=build
+	mkdir $(distdir)/=inst
+	chmod a-w $(distdir)
+	dc_install_base=`$(am__cd) $(distdir)/=inst && pwd` \
+	  && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
+	  && cd $(distdir)/=build \
+	  && ../configure --srcdir=.. --prefix="$$dc_install_base" \
+	    $(DISTCHECK_CONFIGURE_FLAGS) \
+	  && $(MAKE) $(AM_MAKEFLAGS) \
+	  && $(MAKE) $(AM_MAKEFLAGS) dvi \
+	  && $(MAKE) $(AM_MAKEFLAGS) check \
+	  && $(MAKE) $(AM_MAKEFLAGS) install \
+	  && $(MAKE) $(AM_MAKEFLAGS) installcheck \
+	  && $(MAKE) $(AM_MAKEFLAGS) uninstall \
+	  && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
+	        distuninstallcheck \
+	  && chmod -R a-w "$$dc_install_base" \
+	  && ({ \
+	       (cd ../.. && $(mkinstalldirs) "$$dc_destdir") \
+	       && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
+	       && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
+	       && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
+	            distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
+	      } || { rm -rf "$$dc_destdir"; exit 1; }) \
+	  && rm -rf "$$dc_destdir" \
+	  && $(MAKE) $(AM_MAKEFLAGS) dist-gzip \
+	  && rm -f $(distdir).tar.gz \
+	  && $(MAKE) $(AM_MAKEFLAGS) distcleancheck
+	$(am__remove_distdir)
+	@echo "$(distdir).tar.gz is ready for distribution" | \
+	  sed 'h;s/./=/g;p;x;p;x'
+distuninstallcheck:
+	cd $(distuninstallcheck_dir) \
+	&& test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
+	   || { echo "ERROR: files left after uninstall:" ; \
+	        if test -n "$(DESTDIR)"; then \
+	          echo "  (check DESTDIR support)"; \
+	        fi ; \
+	        $(distuninstallcheck_listfiles) ; \
+	        exit 1; } >&2
+distcleancheck: distclean
+	if test '$(srcdir)' = . ; then \
+	  echo "ERROR: distcleancheck can only run from a VPATH build" ; \
+	  exit 1 ; \
+	fi
+	test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
+	  || { echo "ERROR: files left in build directory after distclean:" ; \
+	       $(distcleancheck_listfiles) ; \
+	       exit 1; } >&2
+check-am: all-am
+	$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
+check: check-recursive
+all-am: Makefile $(LTLIBRARIES) uclconf.h
+installdirs: installdirs-recursive
+installdirs-am:
+
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-rm -f Makefile $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-recursive
+
+clean-am: clean-checkPROGRAMS clean-generic clean-libtool \
+	clean-noinstLTLIBRARIES mostlyclean-am
+
+distclean: distclean-recursive
+	-rm -f $(am__CONFIG_DISTCLEAN_FILES)
+distclean-am: clean-am distclean-compile distclean-depend \
+	distclean-generic distclean-hdr distclean-libtool \
+	distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+info: info-recursive
+
+info-am:
+
+install-data-am:
+
+install-exec-am:
+
+install-info: install-info-recursive
+
+install-man:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+	-rm -f $(am__CONFIG_DISTCLEAN_FILES)
+	-rm -rf autom4te.cache
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am: uninstall-info-am
+
+uninstall-info: uninstall-info-recursive
+
+.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am clean \
+	clean-checkPROGRAMS clean-generic clean-libtool \
+	clean-noinstLTLIBRARIES clean-recursive ctags ctags-recursive \
+	dist dist-all dist-gzip distcheck distclean distclean-compile \
+	distclean-depend distclean-generic distclean-hdr \
+	distclean-libtool distclean-recursive distclean-tags \
+	distcleancheck distdir distuninstallcheck dvi dvi-am \
+	dvi-recursive info info-am info-recursive install install-am \
+	install-data install-data-am install-data-recursive \
+	install-exec install-exec-am install-exec-recursive \
+	install-info install-info-am install-info-recursive install-man \
+	install-recursive install-strip installcheck installcheck-am \
+	installdirs installdirs-am installdirs-recursive \
+	maintainer-clean maintainer-clean-generic \
+	maintainer-clean-recursive mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool mostlyclean-recursive \
+	pdf pdf-am pdf-recursive ps ps-am ps-recursive tags \
+	tags-recursive uninstall uninstall-am uninstall-info-am \
+	uninstall-info-recursive uninstall-recursive
+
+version.h: VERSION
+	sed -e 's/.*/#define CCL_VERSION "v&"/' $? > version.h
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:

Added: experimental/j/Elphel333/rtp/daemon/rtp/README
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/README	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/README	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,12 @@
+UCL Common Code Library
+
+Routines common to a number of multimedia tools.  The library
+originates from work on the RAT project: these are portions that are
+not directly related to an audio tool and potentially useful
+elsewhere.  
+
+This library is required to build RAT v3.2.7 or later, and may be
+needed for other UCL tools.
+
+--
+Comments and contributions welcome, please email to mm-tools at cs.ucl.ac.uk.

Added: experimental/j/Elphel333/rtp/daemon/rtp/README.qfdes
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/README.qfdes	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/README.qfdes	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,122 @@
+The qfDES code is derived from Saleem Bhatti's code, but has been significantly
+revised, debugged and updated. The following is the original README, followed
+by some other information which may be useful, taken from Eric Young's libdes.
+
+===============================================================================
+This is yet another implementation of DES in software, for those of us that
+don't have access to DES hardware. The library is fairly (but not quite)
+complete, as are the two progs, qf-des and qf-key. However, debugging and
+testing is still proceeding ...
+
+Quickie Roadmap
+---------------
+
+qf-des: Do DES on files (qf-des.c)
+qf-key: Generate keys and IVs (qf-key.c)
+
+libqfDES.a: library of DES stuff
+
+qfDES.h: Interface file for libqfDES.a
+qfDES.c: The DES function
+
+qfDES-print.c: For generating some of the DES macros and S-Box/P transforms
+
+qfDES-key.c: Key and IV generation
+
+qfDES-memory.c: Fiddling around with memory
+
+Disclaimer
+----------
+This version of the qfDES is for me only, so if you have it and are not me,
+then I take no responsibility for what happens when you use it!
+
+TTFN,
+--/Saleem
+
+===============================================================================
+
+Modes of DES
+Quite a bit of the following information has been taken from
+	AS 2805.5.2
+	Australian Standard
+	Electronic funds transfer - Requirements for interfaces,
+	Part 5.2: Modes of operation for an n-bit block cipher algorithm
+	Appendix A
+
+There are several different modes in which DES can be used, they are
+as follows.
+
+Electronic Codebook Mode (ECB) (des_ecb_encrypt())
+- 64 bits are enciphered at a time.
+- The order of the blocks can be rearranged without detection.
+- The same plaintext block always produces the same ciphertext block
+  (for the same key) making it vulnerable to a 'dictionary attack'.
+- An error will only affect one ciphertext block.
+
+Cipher Block Chaining Mode (CBC) (des_cbc_encrypt())
+- a multiple of 64 bits are enciphered at a time.
+- The CBC mode produces the same ciphertext whenever the same
+  plaintext is encrypted using the same key and starting variable.
+- The chaining operation makes the ciphertext blocks dependent on the
+  current and all preceding plaintext blocks and therefore blocks can not
+  be rearranged.
+- The use of different starting variables prevents the same plaintext
+  enciphering to the same ciphertext.
+- An error will affect the current and the following ciphertext blocks.
+
+Cipher Feedback Mode (CFB) (des_cfb_encrypt())
+- a number of bits (j) <= 64 are enciphered at a time.
+- The CFB mode produces the same ciphertext whenever the same
+  plaintext is encrypted using the same key and starting variable.
+- The chaining operation makes the ciphertext variables dependent on the
+  current and all preceding variables and therefore j-bit variables are
+  chained together and con not be rearranged.
+- The use of different starting variables prevents the same plaintext
+  enciphering to the same ciphertext.
+- The strength of the CFB mode depends on the size of k (maximal if
+  j == k).  In my implementation this is always the case.
+- Selection of a small value for j will require more cycles through
+  the encipherment algorithm per unit of plaintext and thus cause
+  greater processing overheads.
+- Only multiples of j bits can be enciphered.
+- An error will affect the current and the following ciphertext variables.
+
+Output Feedback Mode (OFB) (des_ofb_encrypt())
+- a number of bits (j) <= 64 are enciphered at a time.
+- The OFB mode produces the same ciphertext whenever the same
+  plaintext enciphered using the same key and starting variable.  More
+  over, in the OFB mode the same key stream is produced when the same
+  key and start variable are used.  Consequently, for security reasons
+  a specific start variable should be used only once for a given key.
+- The absence of chaining makes the OFB more vulnerable to specific attacks.
+- The use of different start variables values prevents the same
+  plaintext enciphering to the same ciphertext, by producing different
+  key streams.
+- Selection of a small value for j will require more cycles through
+  the encipherment algorithm per unit of plaintext and thus cause
+  greater processing overheads.
+- Only multiples of j bits can be enciphered.
+- OFB mode of operation does not extend ciphertext errors in the
+  resultant plaintext output.  Every bit error in the ciphertext causes
+  only one bit to be in error in the deciphered plaintext.
+- OFB mode is not self-synchronising.  If the two operation of
+  encipherment and decipherment get out of synchronism, the system needs
+  to be re-initialised.
+- Each re-initialisation should use a value of the start variable
+different from the start variable values used before with the same
+key.  The reason for this is that an identical bit stream would be
+produced each time from the same parameters.  This would be
+susceptible to a ' known plaintext' attack.
+
+Triple ECB Mode (des_3ecb_encrypt())
+- Encrypt with key1, decrypt with key2 and encrypt with key1 again.
+- As for ECB encryption but increases the effective key length to 112 bits.
+- If both keys are the same it is equivalent to encrypting once with
+  just one key.
+
+Triple CBC Mode (des_3cbc_encrypt())
+- Encrypt with key1, decrypt with key2 and encrypt with key1 again.
+- As for CBC encryption but increases the effective key length to 112 bits.
+- If both keys are the same it is equivalent to encrypting once with
+  just one key.
+===============================================================================

Added: experimental/j/Elphel333/rtp/daemon/rtp/VERSION
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/VERSION	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/VERSION	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1 @@
+1.2.8

Added: experimental/j/Elphel333/rtp/daemon/rtp/acconfig.h
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/acconfig.h	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/acconfig.h	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,51 @@
+/*
+ * Define this if you have a /dev/urandom which can supply good random numbers.
+ */
+#undef HAVE_DEV_URANDOM
+
+/*
+ * Define this if you want IPv6 support.
+ */
+#undef HAVE_IPv6
+
+/*
+ * V6 structures that host may or may not be present.
+ */
+#undef HAVE_ST_ADDRINFO
+#undef HAVE_GETIPNODEBYNAME
+#undef HAVE_SIN6_LEN
+
+/*
+ * Define these if your C library is missing some functions...
+ */
+#undef NEED_VSNPRINTF
+#undef NEED_INET_PTON
+#undef NEED_INET_NTOP
+
+/*
+ * If you don't have these types in <inttypes.h>, #define these to be
+ * the types you do have.
+ */
+#undef int8_t
+#undef int16_t
+#undef int32_t
+#undef int64_t
+#undef uint8_t
+#undef uint16_t
+#undef uint32_t
+
+/*
+ * Debugging:
+ * DEBUG: general debugging
+ * DEBUG_MEM: debug memory allocation
+ */
+#undef DEBUG
+#undef DEBUG_MEM
+
+ at BOTTOM@
+
+#ifndef WORDS_BIGENDIAN
+#define WORDS_SMALLENDIAN
+#endif
+
+

Added: experimental/j/Elphel333/rtp/daemon/rtp/aclocal.m4
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/aclocal.m4	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/aclocal.m4	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,4447 @@
+# generated automatically by aclocal 1.7.2 -*- Autoconf -*-
+
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
+# Free Software Foundation, Inc.
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+# Like AC_CONFIG_HEADER, but automatically create stamp file. -*- Autoconf -*-
+
+# Copyright 1996, 1997, 2000, 2001 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+AC_PREREQ([2.52])
+
+# serial 6
+
+# AM_CONFIG_HEADER is obsolete.  It has been replaced by AC_CONFIG_HEADERS.
+AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)])
+
+# Do all the work for Automake.                            -*- Autoconf -*-
+
+# This macro actually does too much some checks are only needed if
+# your package does certain things.  But this isn't really a big deal.
+
+# Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002
+# Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 8
+
+# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
+# written in clear, in which case automake, when reading aclocal.m4,
+# will think it sees a *use*, and therefore will trigger all it's
+# C support machinery.  Also note that it means that autoscan, seeing
+# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
+
+
+AC_PREREQ([2.54])
+
+# Autoconf 2.50 wants to disallow AM_ names.  We explicitly allow
+# the ones we care about.
+m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
+
+# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
+# AM_INIT_AUTOMAKE([OPTIONS])
+# -----------------------------------------------
+# The call with PACKAGE and VERSION arguments is the old style
+# call (pre autoconf-2.50), which is being phased out.  PACKAGE
+# and VERSION should now be passed to AC_INIT and removed from
+# the call to AM_INIT_AUTOMAKE.
+# We support both call styles for the transition.  After
+# the next Automake release, Autoconf can make the AC_INIT
+# arguments mandatory, and then we can depend on a new Autoconf
+# release and drop the old call support.
+AC_DEFUN([AM_INIT_AUTOMAKE],
+[AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
+ AC_REQUIRE([AC_PROG_INSTALL])dnl
+# test to see if srcdir already configured
+if test "`cd $srcdir && pwd`" != "`pwd`" &&
+   test -f $srcdir/config.status; then
+  AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
+fi
+
+# test whether we have cygpath
+if test -z "$CYGPATH_W"; then
+  if (cygpath --version) >/dev/null 2>/dev/null; then
+    CYGPATH_W='cygpath -w'
+  else
+    CYGPATH_W=echo
+  fi
+fi
+AC_SUBST([CYGPATH_W])
+
+# Define the identity of the package.
+dnl Distinguish between old-style and new-style calls.
+m4_ifval([$2],
+[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
+ AC_SUBST([PACKAGE], [$1])dnl
+ AC_SUBST([VERSION], [$2])],
+[_AM_SET_OPTIONS([$1])dnl
+ AC_SUBST([PACKAGE], [AC_PACKAGE_TARNAME])dnl
+ AC_SUBST([VERSION], [AC_PACKAGE_VERSION])])dnl
+
+_AM_IF_OPTION([no-define],,
+[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
+ AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl
+
+# Some tools Automake needs.
+AC_REQUIRE([AM_SANITY_CHECK])dnl
+AC_REQUIRE([AC_ARG_PROGRAM])dnl
+AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version})
+AM_MISSING_PROG(AUTOCONF, autoconf)
+AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version})
+AM_MISSING_PROG(AUTOHEADER, autoheader)
+AM_MISSING_PROG(MAKEINFO, makeinfo)
+AM_MISSING_PROG(AMTAR, tar)
+AM_PROG_INSTALL_SH
+AM_PROG_INSTALL_STRIP
+# We need awk for the "check" target.  The system "awk" is bad on
+# some platforms.
+AC_REQUIRE([AC_PROG_AWK])dnl
+AC_REQUIRE([AC_PROG_MAKE_SET])dnl
+
+_AM_IF_OPTION([no-dependencies],,
+[AC_PROVIDE_IFELSE([AC_PROG_CC],
+                  [_AM_DEPENDENCIES(CC)],
+                  [define([AC_PROG_CC],
+                          defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_CXX],
+                  [_AM_DEPENDENCIES(CXX)],
+                  [define([AC_PROG_CXX],
+                          defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
+])
+])
+
+
+# When config.status generates a header, we must update the stamp-h file.
+# This file resides in the same directory as the config header
+# that is generated.  The stamp files are numbered to have different names.
+
+# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
+# loop where config.status creates the headers, so we can generate
+# our stamp files there.
+AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
+[_am_stamp_count=`expr ${_am_stamp_count-0} + 1`
+echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count])
+
+# Copyright 2002  Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+
+# AM_AUTOMAKE_VERSION(VERSION)
+# ----------------------------
+# Automake X.Y traces this macro to ensure aclocal.m4 has been
+# generated from the m4 files accompanying Automake X.Y.
+AC_DEFUN([AM_AUTOMAKE_VERSION],[am__api_version="1.7"])
+
+# AM_SET_CURRENT_AUTOMAKE_VERSION
+# -------------------------------
+# Call AM_AUTOMAKE_VERSION so it can be traced.
+# This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
+AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
+	 [AM_AUTOMAKE_VERSION([1.7.2])])
+
+# Helper functions for option handling.                    -*- Autoconf -*-
+
+# Copyright 2001, 2002  Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 2
+
+# _AM_MANGLE_OPTION(NAME)
+# -----------------------
+AC_DEFUN([_AM_MANGLE_OPTION],
+[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
+
+# _AM_SET_OPTION(NAME)
+# ------------------------------
+# Set option NAME.  Presently that only means defining a flag for this option.
+AC_DEFUN([_AM_SET_OPTION],
+[m4_define(_AM_MANGLE_OPTION([$1]), 1)])
+
+# _AM_SET_OPTIONS(OPTIONS)
+# ----------------------------------
+# OPTIONS is a space-separated list of Automake options.
+AC_DEFUN([_AM_SET_OPTIONS],
+[AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
+
+# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
+# -------------------------------------------
+# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
+AC_DEFUN([_AM_IF_OPTION],
+[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
+
+#
+# Check to make sure that the build environment is sane.
+#
+
+# Copyright 1996, 1997, 2000, 2001 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 3
+
+# AM_SANITY_CHECK
+# ---------------
+AC_DEFUN([AM_SANITY_CHECK],
+[AC_MSG_CHECKING([whether build environment is sane])
+# Just in case
+sleep 1
+echo timestamp > conftest.file
+# Do `set' in a subshell so we don't clobber the current shell's
+# arguments.  Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+   set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
+   if test "$[*]" = "X"; then
+      # -L didn't work.
+      set X `ls -t $srcdir/configure conftest.file`
+   fi
+   rm -f conftest.file
+   if test "$[*]" != "X $srcdir/configure conftest.file" \
+      && test "$[*]" != "X conftest.file $srcdir/configure"; then
+
+      # If neither matched, then we have a broken ls.  This can happen
+      # if, for instance, CONFIG_SHELL is bash and it inherits a
+      # broken ls alias from the environment.  This has actually
+      # happened.  Such a system could not be considered "sane".
+      AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
+alias in your environment])
+   fi
+
+   test "$[2]" = conftest.file
+   )
+then
+   # Ok.
+   :
+else
+   AC_MSG_ERROR([newly created file is older than distributed files!
+Check your system clock])
+fi
+AC_MSG_RESULT(yes)])
+
+#  -*- Autoconf -*-
+
+
+# Copyright 1997, 1999, 2000, 2001 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 3
+
+# AM_MISSING_PROG(NAME, PROGRAM)
+# ------------------------------
+AC_DEFUN([AM_MISSING_PROG],
+[AC_REQUIRE([AM_MISSING_HAS_RUN])
+$1=${$1-"${am_missing_run}$2"}
+AC_SUBST($1)])
+
+
+# AM_MISSING_HAS_RUN
+# ------------------
+# Define MISSING if not defined so far and test if it supports --run.
+# If it does, set am_missing_run to use it, otherwise, to nothing.
+AC_DEFUN([AM_MISSING_HAS_RUN],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing"
+# Use eval to expand $SHELL
+if eval "$MISSING --run true"; then
+  am_missing_run="$MISSING --run "
+else
+  am_missing_run=
+  AC_MSG_WARN([`missing' script is too old or missing])
+fi
+])
+
+# AM_AUX_DIR_EXPAND
+
+# Copyright 2001 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
+# $ac_aux_dir to `$srcdir/foo'.  In other projects, it is set to
+# `$srcdir', `$srcdir/..', or `$srcdir/../..'.
+#
+# Of course, Automake must honor this variable whenever it calls a
+# tool from the auxiliary directory.  The problem is that $srcdir (and
+# therefore $ac_aux_dir as well) can be either absolute or relative,
+# depending on how configure is run.  This is pretty annoying, since
+# it makes $ac_aux_dir quite unusable in subdirectories: in the top
+# source directory, any form will work fine, but in subdirectories a
+# relative path needs to be adjusted first.
+#
+# $ac_aux_dir/missing
+#    fails when called from a subdirectory if $ac_aux_dir is relative
+# $top_srcdir/$ac_aux_dir/missing
+#    fails if $ac_aux_dir is absolute,
+#    fails when called from a subdirectory in a VPATH build with
+#          a relative $ac_aux_dir
+#
+# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
+# are both prefixed by $srcdir.  In an in-source build this is usually
+# harmless because $srcdir is `.', but things will broke when you
+# start a VPATH build or use an absolute $srcdir.
+#
+# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
+# iff we strip the leading $srcdir from $ac_aux_dir.  That would be:
+#   am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
+# and then we would define $MISSING as
+#   MISSING="\${SHELL} $am_aux_dir/missing"
+# This will work as long as MISSING is not called from configure, because
+# unfortunately $(top_srcdir) has no meaning in configure.
+# However there are other variables, like CC, which are often used in
+# configure, and could therefore not use this "fixed" $ac_aux_dir.
+#
+# Another solution, used here, is to always expand $ac_aux_dir to an
+# absolute PATH.  The drawback is that using absolute paths prevent a
+# configured tree to be moved without reconfiguration.
+
+# Rely on autoconf to set up CDPATH properly.
+AC_PREREQ([2.50])
+
+AC_DEFUN([AM_AUX_DIR_EXPAND], [
+# expand $ac_aux_dir to an absolute path
+am_aux_dir=`cd $ac_aux_dir && pwd`
+])
+
+# AM_PROG_INSTALL_SH
+# ------------------
+# Define $install_sh.
+
+# Copyright 2001 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+AC_DEFUN([AM_PROG_INSTALL_SH],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+install_sh=${install_sh-"$am_aux_dir/install-sh"}
+AC_SUBST(install_sh)])
+
+# AM_PROG_INSTALL_STRIP
+
+# Copyright 2001 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# One issue with vendor `install' (even GNU) is that you can't
+# specify the program used to strip binaries.  This is especially
+# annoying in cross-compiling environments, where the build's strip
+# is unlikely to handle the host's binaries.
+# Fortunately install-sh will honor a STRIPPROG variable, so we
+# always use install-sh in `make install-strip', and initialize
+# STRIPPROG with the value of the STRIP variable (set by the user).
+AC_DEFUN([AM_PROG_INSTALL_STRIP],
+[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
+# Installed binaries are usually stripped using `strip' when the user
+# run `make install-strip'.  However `strip' might not be the right
+# tool to use in cross-compilation environments, therefore Automake
+# will honor the `STRIP' environment variable to overrule this program.
+dnl Don't test for $cross_compiling = yes, because it might be `maybe'.
+if test "$cross_compiling" != no; then
+  AC_CHECK_TOOL([STRIP], [strip], :)
+fi
+INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s"
+AC_SUBST([INSTALL_STRIP_PROGRAM])])
+
+# serial 4						-*- Autoconf -*-
+
+# Copyright 1999, 2000, 2001 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+
+# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
+# written in clear, in which case automake, when reading aclocal.m4,
+# will think it sees a *use*, and therefore will trigger all it's
+# C support machinery.  Also note that it means that autoscan, seeing
+# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
+
+
+
+# _AM_DEPENDENCIES(NAME)
+# ----------------------
+# See how the compiler implements dependency checking.
+# NAME is "CC", "CXX", "GCJ", or "OBJC".
+# We try a few techniques and use that to set a single cache variable.
+#
+# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
+# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
+# dependency, and given that the user is not expected to run this macro,
+# just rely on AC_PROG_CC.
+AC_DEFUN([_AM_DEPENDENCIES],
+[AC_REQUIRE([AM_SET_DEPDIR])dnl
+AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
+AC_REQUIRE([AM_MAKE_INCLUDE])dnl
+AC_REQUIRE([AM_DEP_TRACK])dnl
+
+ifelse([$1], CC,   [depcc="$CC"   am_compiler_list=],
+       [$1], CXX,  [depcc="$CXX"  am_compiler_list=],
+       [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
+       [$1], GCJ,  [depcc="$GCJ"  am_compiler_list='gcc3 gcc'],
+                   [depcc="$$1"   am_compiler_list=])
+
+AC_CACHE_CHECK([dependency style of $depcc],
+               [am_cv_$1_dependencies_compiler_type],
+[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+  # We make a subdir and do the tests there.  Otherwise we can end up
+  # making bogus files that we don't know about and never remove.  For
+  # instance it was reported that on HP-UX the gcc test will end up
+  # making a dummy file named `D' -- because `-MD' means `put the output
+  # in D'.
+  mkdir conftest.dir
+  # Copy depcomp to subdir because otherwise we won't find it if we're
+  # using a relative directory.
+  cp "$am_depcomp" conftest.dir
+  cd conftest.dir
+
+  am_cv_$1_dependencies_compiler_type=none
+  if test "$am_compiler_list" = ""; then
+     am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
+  fi
+  for depmode in $am_compiler_list; do
+    # We need to recreate these files for each test, as the compiler may
+    # overwrite some of them when testing with obscure command lines.
+    # This happens at least with the AIX C compiler.
+    echo '#include "conftest.h"' > conftest.c
+    echo 'int i;' > conftest.h
+    echo "${am__include} ${am__quote}conftest.Po${am__quote}" > confmf
+
+    case $depmode in
+    nosideeffect)
+      # after this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested
+      if test "x$enable_dependency_tracking" = xyes; then
+	continue
+      else
+	break
+      fi
+      ;;
+    none) break ;;
+    esac
+    # We check with `-c' and `-o' for the sake of the "dashmstdout"
+    # mode.  It turns out that the SunPro C++ compiler does not properly
+    # handle `-M -o', and we need to detect this.
+    if depmode=$depmode \
+       source=conftest.c object=conftest.o \
+       depfile=conftest.Po tmpdepfile=conftest.TPo \
+       $SHELL ./depcomp $depcc -c -o conftest.o conftest.c >/dev/null 2>&1 &&
+       grep conftest.h conftest.Po > /dev/null 2>&1 &&
+       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+      am_cv_$1_dependencies_compiler_type=$depmode
+      break
+    fi
+  done
+
+  cd ..
+  rm -rf conftest.dir
+else
+  am_cv_$1_dependencies_compiler_type=none
+fi
+])
+AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
+AM_CONDITIONAL([am__fastdep$1], [
+  test "x$enable_dependency_tracking" != xno \
+  && test "$am_cv_$1_dependencies_compiler_type" = gcc3])
+])
+
+
+# AM_SET_DEPDIR
+# -------------
+# Choose a directory name for dependency files.
+# This macro is AC_REQUIREd in _AM_DEPENDENCIES
+AC_DEFUN([AM_SET_DEPDIR],
+[rm -f .deps 2>/dev/null
+mkdir .deps 2>/dev/null
+if test -d .deps; then
+  DEPDIR=.deps
+else
+  # MS-DOS does not allow filenames that begin with a dot.
+  DEPDIR=_deps
+fi
+rmdir .deps 2>/dev/null
+AC_SUBST([DEPDIR])
+])
+
+
+# AM_DEP_TRACK
+# ------------
+AC_DEFUN([AM_DEP_TRACK],
+[AC_ARG_ENABLE(dependency-tracking,
+[  --disable-dependency-tracking Speeds up one-time builds
+  --enable-dependency-tracking  Do not reject slow dependency extractors])
+if test "x$enable_dependency_tracking" != xno; then
+  am_depcomp="$ac_aux_dir/depcomp"
+  AMDEPBACKSLASH='\'
+fi
+AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
+AC_SUBST([AMDEPBACKSLASH])
+])
+
+# Generate code to set up dependency tracking.   -*- Autoconf -*-
+
+# Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+#serial 2
+
+# _AM_OUTPUT_DEPENDENCY_COMMANDS
+# ------------------------------
+AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
+[for mf in $CONFIG_FILES; do
+  # Strip MF so we end up with the name of the file.
+  mf=`echo "$mf" | sed -e 's/:.*$//'`
+  # Check whether this is an Automake generated Makefile or not.
+  # We used to match only the files named `Makefile.in', but
+  # some people rename them; so instead we look at the file content.
+  # Grep'ing the first line is not enough: some people post-process
+  # each Makefile.in and add a new line on top of each file to say so.
+  # So let's grep whole file.
+  if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then
+    dirpart=`AS_DIRNAME("$mf")`
+  else
+    continue
+  fi
+  grep '^DEP_FILES *= *[[^ @%:@]]' < "$mf" > /dev/null || continue
+  # Extract the definition of DEP_FILES from the Makefile without
+  # running `make'.
+  DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"`
+  test -z "$DEPDIR" && continue
+  # When using ansi2knr, U may be empty or an underscore; expand it
+  U=`sed -n -e '/^U = / s///p' < "$mf"`
+  test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR"
+  # We invoke sed twice because it is the simplest approach to
+  # changing $(DEPDIR) to its actual value in the expansion.
+  for file in `sed -n -e '
+    /^DEP_FILES = .*\\\\$/ {
+      s/^DEP_FILES = //
+      :loop
+	s/\\\\$//
+	p
+	n
+	/\\\\$/ b loop
+      p
+    }
+    /^DEP_FILES = / s/^DEP_FILES = //p' < "$mf" | \
+       sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
+    # Make sure the directory exists.
+    test -f "$dirpart/$file" && continue
+    fdir=`AS_DIRNAME(["$file"])`
+    AS_MKDIR_P([$dirpart/$fdir])
+    # echo "creating $dirpart/$file"
+    echo '# dummy' > "$dirpart/$file"
+  done
+done
+])# _AM_OUTPUT_DEPENDENCY_COMMANDS
+
+
+# AM_OUTPUT_DEPENDENCY_COMMANDS
+# -----------------------------
+# This macro should only be invoked once -- use via AC_REQUIRE.
+#
+# This code is only required when automatic dependency tracking
+# is enabled.  FIXME.  This creates each `.P' file that we will
+# need in order to bootstrap the dependency handling code.
+AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
+[AC_CONFIG_COMMANDS([depfiles],
+     [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
+     [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
+])
+
+# Check to see how 'make' treats includes.	-*- Autoconf -*-
+
+# Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 2
+
+# AM_MAKE_INCLUDE()
+# -----------------
+# Check to see how make treats includes.
+AC_DEFUN([AM_MAKE_INCLUDE],
+[am_make=${MAKE-make}
+cat > confinc << 'END'
+doit:
+	@echo done
+END
+# If we don't find an include directive, just comment out the code.
+AC_MSG_CHECKING([for style of include used by $am_make])
+am__include="#"
+am__quote=
+_am_result=none
+# First try GNU make style include.
+echo "include confinc" > confmf
+# We grep out `Entering directory' and `Leaving directory'
+# messages which can occur if `w' ends up in MAKEFLAGS.
+# In particular we don't look at `^make:' because GNU make might
+# be invoked under some other name (usually "gmake"), in which
+# case it prints its new name instead of `make'.
+if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then
+   am__include=include
+   am__quote=
+   _am_result=GNU
+fi
+# Now try BSD make style include.
+if test "$am__include" = "#"; then
+   echo '.include "confinc"' > confmf
+   if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then
+      am__include=.include
+      am__quote="\""
+      _am_result=BSD
+   fi
+fi
+AC_SUBST(am__include)
+AC_SUBST(am__quote)
+AC_MSG_RESULT($_am_result)
+rm -f confinc confmf
+])
+
+# AM_CONDITIONAL                                              -*- Autoconf -*-
+
+# Copyright 1997, 2000, 2001 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 5
+
+AC_PREREQ(2.52)
+
+# AM_CONDITIONAL(NAME, SHELL-CONDITION)
+# -------------------------------------
+# Define a conditional.
+AC_DEFUN([AM_CONDITIONAL],
+[ifelse([$1], [TRUE],  [AC_FATAL([$0: invalid condition: $1])],
+        [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
+AC_SUBST([$1_TRUE])
+AC_SUBST([$1_FALSE])
+if $2; then
+  $1_TRUE=
+  $1_FALSE='#'
+else
+  $1_TRUE='#'
+  $1_FALSE=
+fi
+AC_CONFIG_COMMANDS_PRE(
+[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
+  AC_MSG_ERROR([conditional "$1" was never defined.
+Usually this means the macro was only invoked conditionally.])
+fi])])
+
+# libtool.m4 - Configure libtool for the host system. -*-Shell-script-*-
+
+# serial 46 AC_PROG_LIBTOOL
+
+AC_DEFUN([AC_PROG_LIBTOOL],
+[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl
+
+# This can be used to rebuild libtool when needed
+LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh"
+
+# Always use our own libtool.
+LIBTOOL='$(SHELL) $(top_builddir)/libtool'
+AC_SUBST(LIBTOOL)dnl
+
+# Prevent multiple expansion
+define([AC_PROG_LIBTOOL], [])
+])
+
+AC_DEFUN([AC_LIBTOOL_SETUP],
+[AC_PREREQ(2.13)dnl
+AC_REQUIRE([AC_ENABLE_SHARED])dnl
+AC_REQUIRE([AC_ENABLE_STATIC])dnl
+AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl
+AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_PROG_LD])dnl
+AC_REQUIRE([AC_PROG_LD_RELOAD_FLAG])dnl
+AC_REQUIRE([AC_PROG_NM])dnl
+AC_REQUIRE([LT_AC_PROG_SED])dnl
+
+AC_REQUIRE([AC_PROG_LN_S])dnl
+AC_REQUIRE([AC_DEPLIBS_CHECK_METHOD])dnl
+AC_REQUIRE([AC_OBJEXT])dnl
+AC_REQUIRE([AC_EXEEXT])dnl
+dnl
+
+_LT_AC_PROG_ECHO_BACKSLASH
+# Only perform the check for file, if the check method requires it
+case $deplibs_check_method in
+file_magic*)
+  if test "$file_magic_cmd" = '$MAGIC_CMD'; then
+    AC_PATH_MAGIC
+  fi
+  ;;
+esac
+
+AC_CHECK_TOOL(RANLIB, ranlib, :)
+AC_CHECK_TOOL(STRIP, strip, :)
+
+ifdef([AC_PROVIDE_AC_LIBTOOL_DLOPEN], enable_dlopen=yes, enable_dlopen=no)
+ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
+enable_win32_dll=yes, enable_win32_dll=no)
+
+AC_ARG_ENABLE(libtool-lock,
+  [  --disable-libtool-lock  avoid locking (might break parallel builds)])
+test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+
+# Some flags need to be propagated to the compiler or linker for good
+# libtool support.
+case $host in
+*-*-irix6*)
+  # Find out which ABI we are using.
+  echo '[#]line __oline__ "configure"' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+    case `/usr/bin/file conftest.$ac_objext` in
+    *32-bit*)
+      LD="${LD-ld} -32"
+      ;;
+    *N32*)
+      LD="${LD-ld} -n32"
+      ;;
+    *64-bit*)
+      LD="${LD-ld} -64"
+      ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+
+*-*-linux*)
+  # Test if the compiler is 64bit
+  echo 'int i;' > conftest.$ac_ext
+  lt_cv_cc_64bit_output=no
+  if AC_TRY_EVAL(ac_compile); then
+    case `/usr/bin/file conftest.$ac_objext` in
+    *"ELF 64"*)
+      lt_cv_cc_64bit_output=yes
+      ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+  
+*-*-sco3.2v5*)
+  # On SCO OpenServer 5, we need -belf to get full-featured binaries.
+  SAVE_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -belf"
+  AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
+    [AC_LANG_SAVE
+     AC_LANG_C
+     AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
+     AC_LANG_RESTORE])
+  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
+    CFLAGS="$SAVE_CFLAGS"
+  fi
+  ;;
+
+ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
+[*-*-cygwin* | *-*-mingw* | *-*-pw32*)
+  AC_CHECK_TOOL(DLLTOOL, dlltool, false)
+  AC_CHECK_TOOL(AS, as, false)
+  AC_CHECK_TOOL(OBJDUMP, objdump, false)
+
+  # recent cygwin and mingw systems supply a stub DllMain which the user
+  # can override, but on older systems we have to supply one
+  AC_CACHE_CHECK([if libtool should supply DllMain function], lt_cv_need_dllmain,
+    [AC_TRY_LINK([],
+      [extern int __attribute__((__stdcall__)) DllMain(void*, int, void*);
+      DllMain (0, 0, 0);],
+      [lt_cv_need_dllmain=no],[lt_cv_need_dllmain=yes])])
+
+  case $host/$CC in
+  *-*-cygwin*/gcc*-mno-cygwin*|*-*-mingw*)
+    # old mingw systems require "-dll" to link a DLL, while more recent ones
+    # require "-mdll"
+    SAVE_CFLAGS="$CFLAGS"
+    CFLAGS="$CFLAGS -mdll"
+    AC_CACHE_CHECK([how to link DLLs], lt_cv_cc_dll_switch,
+      [AC_TRY_LINK([], [], [lt_cv_cc_dll_switch=-mdll],[lt_cv_cc_dll_switch=-dll])])
+    CFLAGS="$SAVE_CFLAGS" ;;
+  *-*-cygwin* | *-*-pw32*)
+    # cygwin systems need to pass --dll to the linker, and not link
+    # crt.o which will require a WinMain at 16 definition.
+    lt_cv_cc_dll_switch="-Wl,--dll -nostartfiles" ;;
+  esac
+  ;;
+  ])
+esac
+
+_LT_AC_LTCONFIG_HACK
+
+])
+
+# AC_LIBTOOL_HEADER_ASSERT
+# ------------------------
+AC_DEFUN([AC_LIBTOOL_HEADER_ASSERT],
+[AC_CACHE_CHECK([whether $CC supports assert without backlinking],
+    [lt_cv_func_assert_works],
+    [case $host in
+    *-*-solaris*)
+      if test "$GCC" = yes && test "$with_gnu_ld" != yes; then
+        case `$CC --version 2>/dev/null` in
+        [[12]].*) lt_cv_func_assert_works=no ;;
+        *)        lt_cv_func_assert_works=yes ;;
+        esac
+      fi
+      ;;
+    esac])
+
+if test "x$lt_cv_func_assert_works" = xyes; then
+  AC_CHECK_HEADERS(assert.h)
+fi
+])# AC_LIBTOOL_HEADER_ASSERT
+
+# _LT_AC_CHECK_DLFCN
+# --------------------
+AC_DEFUN([_LT_AC_CHECK_DLFCN],
+[AC_CHECK_HEADERS(dlfcn.h)
+])# _LT_AC_CHECK_DLFCN
+
+# AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
+# ---------------------------------
+AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE],
+[AC_REQUIRE([AC_CANONICAL_HOST])
+AC_REQUIRE([AC_PROG_NM])
+AC_REQUIRE([AC_OBJEXT])
+# Check for command to grab the raw symbol name followed by C symbol from nm.
+AC_MSG_CHECKING([command to parse $NM output])
+AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], [dnl
+
+# These are sane defaults that work on at least a few old systems.
+# [They come from Ultrix.  What could be older than Ultrix?!! ;)]
+
+# Character class describing NM global symbol codes.
+symcode='[[BCDEGRST]]'
+
+# Regexp to match symbols that can be accessed directly from C.
+sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)'
+
+# Transform the above into a raw symbol and a C symbol.
+symxfrm='\1 \2\3 \3'
+
+# Transform an extracted symbol line into a proper C declaration
+lt_cv_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern char \1;/p'"
+
+# Transform an extracted symbol line into symbol name and symbol address
+lt_cv_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/  {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([[^ ]]*\) \([[^ ]]*\)$/  {\"\2\", (lt_ptr) \&\2},/p'"
+
+# Define system-specific variables.
+case $host_os in
+aix*)
+  symcode='[[BCDT]]'
+  ;;
+cygwin* | mingw* | pw32*)
+  symcode='[[ABCDGISTW]]'
+  ;;
+hpux*) # Its linker distinguishes data from code symbols
+  lt_cv_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern char \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+  lt_cv_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/  {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"\2\", (lt_ptr) \&\2},/p'"
+  ;;
+irix* | nonstopux*)
+  symcode='[[BCDEGRST]]'
+  ;;
+osf*)
+  symcode='[[BCDEGQRST]]'
+  ;;
+solaris* | sysv5*)
+  symcode='[[BDT]]'
+  ;;
+sysv4)
+  symcode='[[DFNSTU]]'
+  ;;
+esac
+
+# Handle CRLF in mingw tool chain
+opt_cr=
+case $host_os in
+mingw*)
+  opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp
+  ;;
+esac
+
+# If we're using GNU nm, then use its standard symbol codes.
+if $NM -V 2>&1 | egrep '(GNU|with BFD)' > /dev/null; then
+  symcode='[[ABCDGISTW]]'
+fi
+
+# Try without a prefix undercore, then with it.
+for ac_symprfx in "" "_"; do
+
+  # Write the raw and C identifiers.
+lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ 	]]\($symcode$symcode*\)[[ 	]][[ 	]]*\($ac_symprfx\)$sympat$opt_cr$/$symxfrm/p'"
+
+  # Check to see that the pipe works correctly.
+  pipe_works=no
+  rm -f conftest*
+  cat > conftest.$ac_ext <<EOF
+#ifdef __cplusplus
+extern "C" {
+#endif
+char nm_test_var;
+void nm_test_func(){}
+#ifdef __cplusplus
+}
+#endif
+int main(){nm_test_var='a';nm_test_func();return(0);}
+EOF
+
+  if AC_TRY_EVAL(ac_compile); then
+    # Now try to grab the symbols.
+    nlist=conftest.nm
+    if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) && test -s "$nlist"; then
+      # Try sorting and uniquifying the output.
+      if sort "$nlist" | uniq > "$nlist"T; then
+	mv -f "$nlist"T "$nlist"
+      else
+	rm -f "$nlist"T
+      fi
+
+      # Make sure that we snagged all the symbols we need.
+      if egrep ' nm_test_var$' "$nlist" >/dev/null; then
+	if egrep ' nm_test_func$' "$nlist" >/dev/null; then
+	  cat <<EOF > conftest.$ac_ext
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+EOF
+	  # Now generate the symbol file.
+	  eval "$lt_cv_global_symbol_to_cdecl"' < "$nlist" >> conftest.$ac_ext'
+
+	  cat <<EOF >> conftest.$ac_ext
+#if defined (__STDC__) && __STDC__
+# define lt_ptr void *
+#else
+# define lt_ptr char *
+# define const
+#endif
+
+/* The mapping between symbol names and symbols. */
+const struct {
+  const char *name;
+  lt_ptr address;
+}
+lt_preloaded_symbols[[]] =
+{
+EOF
+	  sed "s/^$symcode$symcode* \(.*\) \(.*\)$/  {\"\2\", (lt_ptr) \&\2},/" < "$nlist" >> conftest.$ac_ext
+	  cat <<\EOF >> conftest.$ac_ext
+  {0, (lt_ptr) 0}
+};
+
+#ifdef __cplusplus
+}
+#endif
+EOF
+	  # Now try linking the two files.
+	  mv conftest.$ac_objext conftstm.$ac_objext
+	  save_LIBS="$LIBS"
+	  save_CFLAGS="$CFLAGS"
+	  LIBS="conftstm.$ac_objext"
+	  CFLAGS="$CFLAGS$no_builtin_flag"
+	  if AC_TRY_EVAL(ac_link) && test -s conftest$ac_exeext; then
+	    pipe_works=yes
+	  fi
+	  LIBS="$save_LIBS"
+	  CFLAGS="$save_CFLAGS"
+	else
+	  echo "cannot find nm_test_func in $nlist" >&AC_FD_CC
+	fi
+      else
+	echo "cannot find nm_test_var in $nlist" >&AC_FD_CC
+      fi
+    else
+      echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AC_FD_CC
+    fi
+  else
+    echo "$progname: failed program was:" >&AC_FD_CC
+    cat conftest.$ac_ext >&5
+  fi
+  rm -f conftest* conftst*
+
+  # Do not use the global_symbol_pipe unless it works.
+  if test "$pipe_works" = yes; then
+    break
+  else
+    lt_cv_sys_global_symbol_pipe=
+  fi
+done
+])
+global_symbol_pipe="$lt_cv_sys_global_symbol_pipe"
+if test -z "$lt_cv_sys_global_symbol_pipe"; then
+  global_symbol_to_cdecl=
+  global_symbol_to_c_name_address=
+else
+  global_symbol_to_cdecl="$lt_cv_global_symbol_to_cdecl"
+  global_symbol_to_c_name_address="$lt_cv_global_symbol_to_c_name_address"
+fi
+if test -z "$global_symbol_pipe$global_symbol_to_cdec$global_symbol_to_c_name_address";
+then
+  AC_MSG_RESULT(failed)
+else
+  AC_MSG_RESULT(ok)
+fi
+]) # AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
+
+# _LT_AC_LIBTOOL_SYS_PATH_SEPARATOR
+# ---------------------------------
+AC_DEFUN([_LT_AC_LIBTOOL_SYS_PATH_SEPARATOR],
+[# Find the correct PATH separator.  Usually this is `:', but
+# DJGPP uses `;' like DOS.
+if test "X${PATH_SEPARATOR+set}" != Xset; then
+  UNAME=${UNAME-`uname 2>/dev/null`}
+  case X$UNAME in
+    *-DOS) lt_cv_sys_path_separator=';' ;;
+    *)     lt_cv_sys_path_separator=':' ;;
+  esac
+  PATH_SEPARATOR=$lt_cv_sys_path_separator
+fi
+])# _LT_AC_LIBTOOL_SYS_PATH_SEPARATOR
+
+# _LT_AC_PROG_ECHO_BACKSLASH
+# --------------------------
+# Add some code to the start of the generated configure script which
+# will find an echo command which doesn't interpret backslashes.
+AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH],
+[ifdef([AC_DIVERSION_NOTICE], [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)],
+			      [AC_DIVERT_PUSH(NOTICE)])
+_LT_AC_LIBTOOL_SYS_PATH_SEPARATOR
+
+# Check that we are running under the correct shell.
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+case X$ECHO in
+X*--fallback-echo)
+  # Remove one level of quotation (which was required for Make).
+  ECHO=`echo "$ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','`
+  ;;
+esac
+
+echo=${ECHO-echo}
+if test "X[$]1" = X--no-reexec; then
+  # Discard the --no-reexec flag, and continue.
+  shift
+elif test "X[$]1" = X--fallback-echo; then
+  # Avoid inline document here, it may be left over
+  :
+elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
+  # Yippee, $echo works!
+  :
+else
+  # Restart under the correct shell.
+  exec $SHELL "[$]0" --no-reexec ${1+"[$]@"}
+fi
+
+if test "X[$]1" = X--fallback-echo; then
+  # used as fallback echo
+  shift
+  cat <<EOF
+$*
+EOF
+  exit 0
+fi
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+if test "X${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi
+
+if test -z "$ECHO"; then
+if test "X${echo_test_string+set}" != Xset; then
+# find a string as large as possible, as long as the shell can cope with it
+  for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do
+    # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
+    if (echo_test_string="`eval $cmd`") 2>/dev/null &&
+       echo_test_string="`eval $cmd`" &&
+       (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null
+    then
+      break
+    fi
+  done
+fi
+
+if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
+   echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` &&
+   test "X$echo_testing_string" = "X$echo_test_string"; then
+  :
+else
+  # The Solaris, AIX, and Digital Unix default echo programs unquote
+  # backslashes.  This makes it impossible to quote backslashes using
+  #   echo "$something" | sed 's/\\/\\\\/g'
+  #
+  # So, first we look for a working echo in the user's PATH.
+
+  IFS="${IFS= 	}"; save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  for dir in $PATH /usr/ucb; do
+    if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
+       test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
+       echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` &&
+       test "X$echo_testing_string" = "X$echo_test_string"; then
+      echo="$dir/echo"
+      break
+    fi
+  done
+  IFS="$save_ifs"
+
+  if test "X$echo" = Xecho; then
+    # We didn't find a better echo, so look for alternatives.
+    if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' &&
+       echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` &&
+       test "X$echo_testing_string" = "X$echo_test_string"; then
+      # This shell has a builtin print -r that does the trick.
+      echo='print -r'
+    elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) &&
+	 test "X$CONFIG_SHELL" != X/bin/ksh; then
+      # If we have ksh, try running configure again with it.
+      ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
+      export ORIGINAL_CONFIG_SHELL
+      CONFIG_SHELL=/bin/ksh
+      export CONFIG_SHELL
+      exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"}
+    else
+      # Try using printf.
+      echo='printf %s\n'
+      if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
+	 echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` &&
+	 test "X$echo_testing_string" = "X$echo_test_string"; then
+	# Cool, printf works
+	:
+      elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
+	   test "X$echo_testing_string" = 'X\t' &&
+	   echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
+	   test "X$echo_testing_string" = "X$echo_test_string"; then
+	CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL
+	export CONFIG_SHELL
+	SHELL="$CONFIG_SHELL"
+	export SHELL
+	echo="$CONFIG_SHELL [$]0 --fallback-echo"
+      elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
+	   test "X$echo_testing_string" = 'X\t' &&
+	   echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
+	   test "X$echo_testing_string" = "X$echo_test_string"; then
+	echo="$CONFIG_SHELL [$]0 --fallback-echo"
+      else
+	# maybe with a smaller string...
+	prev=:
+
+	for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do
+	  if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null
+	  then
+	    break
+	  fi
+	  prev="$cmd"
+	done
+
+	if test "$prev" != 'sed 50q "[$]0"'; then
+	  echo_test_string=`eval $prev`
+	  export echo_test_string
+	  exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"}
+	else
+	  # Oops.  We lost completely, so just stick with echo.
+	  echo=echo
+	fi
+      fi
+    fi
+  fi
+fi
+fi
+
+# Copy echo and quote the copy suitably for passing to libtool from
+# the Makefile, instead of quoting the original, which is used later.
+ECHO=$echo
+if test "X$ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then
+   ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo"
+fi
+
+AC_SUBST(ECHO)
+AC_DIVERT_POP
+])# _LT_AC_PROG_ECHO_BACKSLASH
+
+# _LT_AC_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE,
+#                           ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING)
+# ------------------------------------------------------------------
+AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF],
+[if test "$cross_compiling" = yes; then :
+  [$4]
+else
+  AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl
+  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+  lt_status=$lt_dlunknown
+  cat > conftest.$ac_ext <<EOF
+[#line __oline__ "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+#  define LT_DLGLOBAL		RTLD_GLOBAL
+#else
+#  ifdef DL_GLOBAL
+#    define LT_DLGLOBAL		DL_GLOBAL
+#  else
+#    define LT_DLGLOBAL		0
+#  endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+   find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+#  ifdef RTLD_LAZY
+#    define LT_DLLAZY_OR_NOW		RTLD_LAZY
+#  else
+#    ifdef DL_LAZY
+#      define LT_DLLAZY_OR_NOW		DL_LAZY
+#    else
+#      ifdef RTLD_NOW
+#        define LT_DLLAZY_OR_NOW	RTLD_NOW
+#      else
+#        ifdef DL_NOW
+#          define LT_DLLAZY_OR_NOW	DL_NOW
+#        else
+#          define LT_DLLAZY_OR_NOW	0
+#        endif
+#      endif
+#    endif
+#  endif
+#endif
+
+#ifdef __cplusplus
+extern "C" void exit (int);
+#endif
+
+void fnord() { int i=42;}
+int main ()
+{
+  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+  int status = $lt_dlunknown;
+
+  if (self)
+    {
+      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
+      else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+      /* dlclose (self); */
+    }
+
+    exit (status);
+}]
+EOF
+  if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
+    (./conftest; exit; ) 2>/dev/null
+    lt_status=$?
+    case x$lt_status in
+      x$lt_dlno_uscore) $1 ;;
+      x$lt_dlneed_uscore) $2 ;;
+      x$lt_unknown|x*) $3 ;;
+    esac
+  else :
+    # compilation failed
+    $3
+  fi
+fi
+rm -fr conftest*
+])# _LT_AC_TRY_DLOPEN_SELF
+
+# AC_LIBTOOL_DLOPEN_SELF
+# -------------------
+AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF],
+[if test "x$enable_dlopen" != xyes; then
+  enable_dlopen=unknown
+  enable_dlopen_self=unknown
+  enable_dlopen_self_static=unknown
+else
+  lt_cv_dlopen=no
+  lt_cv_dlopen_libs=
+
+  case $host_os in
+  beos*)
+    lt_cv_dlopen="load_add_on"
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
+    ;;
+
+  cygwin* | mingw* | pw32*)
+    lt_cv_dlopen="LoadLibrary"
+    lt_cv_dlopen_libs=
+   ;;
+
+  *)
+    AC_CHECK_FUNC([shl_load],
+          [lt_cv_dlopen="shl_load"],
+      [AC_CHECK_LIB([dld], [shl_load],
+            [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"],
+	[AC_CHECK_FUNC([dlopen],
+	      [lt_cv_dlopen="dlopen"],
+	  [AC_CHECK_LIB([dl], [dlopen],
+	        [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],
+	    [AC_CHECK_LIB([svld], [dlopen],
+	          [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
+	      [AC_CHECK_LIB([dld], [dld_link],
+	            [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"])
+	      ])
+	    ])
+	  ])
+	])
+      ])
+    ;;
+  esac
+
+  if test "x$lt_cv_dlopen" != xno; then
+    enable_dlopen=yes
+  else
+    enable_dlopen=no
+  fi
+
+  case $lt_cv_dlopen in
+  dlopen)
+    save_CPPFLAGS="$CPPFLAGS"
+    AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl
+    test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+
+    save_LDFLAGS="$LDFLAGS"
+    eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+
+    save_LIBS="$LIBS"
+    LIBS="$lt_cv_dlopen_libs $LIBS"
+
+    AC_CACHE_CHECK([whether a program can dlopen itself],
+	  lt_cv_dlopen_self, [dnl
+	  _LT_AC_TRY_DLOPEN_SELF(
+	    lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes,
+	    lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross)
+    ])
+
+    if test "x$lt_cv_dlopen_self" = xyes; then
+      LDFLAGS="$LDFLAGS $link_static_flag"
+      AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
+    	  lt_cv_dlopen_self_static, [dnl
+	  _LT_AC_TRY_DLOPEN_SELF(
+	    lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes,
+	    lt_cv_dlopen_self_static=no,  lt_cv_dlopen_self_static=cross)
+      ])
+    fi
+
+    CPPFLAGS="$save_CPPFLAGS"
+    LDFLAGS="$save_LDFLAGS"
+    LIBS="$save_LIBS"
+    ;;
+  esac
+
+  case $lt_cv_dlopen_self in
+  yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+  *) enable_dlopen_self=unknown ;;
+  esac
+
+  case $lt_cv_dlopen_self_static in
+  yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+  *) enable_dlopen_self_static=unknown ;;
+  esac
+fi
+])# AC_LIBTOOL_DLOPEN_SELF
+
+AC_DEFUN([_LT_AC_LTCONFIG_HACK],
+[AC_REQUIRE([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])dnl
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed='sed -e s/^X//'
+sed_quote_subst='s/\([[\\"\\`$\\\\]]\)/\\\1/g'
+
+# Same as above, but do not quote variable references.
+double_quote_subst='s/\([[\\"\\`\\\\]]\)/\\\1/g'
+
+# Sed substitution to delay expansion of an escaped shell variable in a
+# double_quote_subst'ed string.
+delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
+
+# Constants:
+rm="rm -f"
+
+# Global variables:
+default_ofile=libtool
+can_build_shared=yes
+
+# All known linkers require a `.a' archive for static linking (except M$VC,
+# which needs '.lib').
+libext=a
+ltmain="$ac_aux_dir/ltmain.sh"
+ofile="$default_ofile"
+with_gnu_ld="$lt_cv_prog_gnu_ld"
+need_locks="$enable_libtool_lock"
+
+old_CC="$CC"
+old_CFLAGS="$CFLAGS"
+
+# Set sane defaults for various variables
+test -z "$AR" && AR=ar
+test -z "$AR_FLAGS" && AR_FLAGS=cru
+test -z "$AS" && AS=as
+test -z "$CC" && CC=cc
+test -z "$DLLTOOL" && DLLTOOL=dlltool
+test -z "$LD" && LD=ld
+test -z "$LN_S" && LN_S="ln -s"
+test -z "$MAGIC_CMD" && MAGIC_CMD=file
+test -z "$NM" && NM=nm
+test -z "$OBJDUMP" && OBJDUMP=objdump
+test -z "$RANLIB" && RANLIB=:
+test -z "$STRIP" && STRIP=:
+test -z "$ac_objext" && ac_objext=o
+
+if test x"$host" != x"$build"; then
+  ac_tool_prefix=${host_alias}-
+else
+  ac_tool_prefix=
+fi
+
+case $host_os in
+aix3*)
+  # AIX sometimes has problems with the GCC collect2 program.  For some
+  # reason, if we set the COLLECT_NAMES environment variable, the problems
+  # vanish in a puff of smoke.
+  if test "X${COLLECT_NAMES+set}" != Xset; then
+    COLLECT_NAMES=
+    export COLLECT_NAMES
+  fi
+  ;;
+esac
+
+# Determine commands to create old-style static archives.
+old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs'
+old_postinstall_cmds='chmod 644 $oldlib'
+old_postuninstall_cmds=
+
+if test -n "$RANLIB"; then
+  case $host_os in
+  openbsd*)
+    old_postinstall_cmds="\$RANLIB -t \$oldlib~$old_postinstall_cmds"
+    ;;
+  *)
+    old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds"
+    ;;
+  esac
+  old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
+fi
+
+# Allow CC to be a program name with arguments.
+set dummy $CC
+compiler="[$]2"
+
+AC_MSG_CHECKING([for objdir])
+rm -f .libs 2>/dev/null
+mkdir .libs 2>/dev/null
+if test -d .libs; then
+  objdir=.libs
+else
+  # MS-DOS does not allow filenames that begin with a dot.
+  objdir=_libs
+fi
+rmdir .libs 2>/dev/null
+AC_MSG_RESULT($objdir)
+
+
+AC_ARG_WITH(pic,
+[  --with-pic              try to use only PIC/non-PIC objects [default=use both]],
+pic_mode="$withval", pic_mode=default)
+test -z "$pic_mode" && pic_mode=default
+
+# We assume here that the value for lt_cv_prog_cc_pic will not be cached
+# in isolation, and that seeing it set (from the cache) indicates that
+# the associated values are set (in the cache) correctly too.
+AC_MSG_CHECKING([for $compiler option to produce PIC])
+AC_CACHE_VAL(lt_cv_prog_cc_pic,
+[ lt_cv_prog_cc_pic=
+  lt_cv_prog_cc_shlib=
+  lt_cv_prog_cc_wl=
+  lt_cv_prog_cc_static=
+  lt_cv_prog_cc_no_builtin=
+  lt_cv_prog_cc_can_build_shared=$can_build_shared
+
+  if test "$GCC" = yes; then
+    lt_cv_prog_cc_wl='-Wl,'
+    lt_cv_prog_cc_static='-static'
+
+    case $host_os in
+    aix*)
+      # Below there is a dirty hack to force normal static linking with -ldl
+      # The problem is because libdl dynamically linked with both libc and
+      # libC (AIX C++ library), which obviously doesn't included in libraries
+      # list by gcc. This cause undefined symbols with -static flags.
+      # This hack allows C programs to be linked with "-static -ldl", but
+      # not sure about C++ programs.
+      lt_cv_prog_cc_static="$lt_cv_prog_cc_static ${lt_cv_prog_cc_wl}-lC"
+      ;;
+    amigaos*)
+      # FIXME: we need at least 68020 code to build shared libraries, but
+      # adding the `-m68020' flag to GCC prevents building anything better,
+      # like `-m68040'.
+      lt_cv_prog_cc_pic='-m68020 -resident32 -malways-restore-a4'
+      ;;
+    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+      # PIC is the default for these OSes.
+      ;;
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      lt_cv_prog_cc_pic='-fno-common'
+      ;;
+    cygwin* | mingw* | pw32* | os2*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      lt_cv_prog_cc_pic='-DDLL_EXPORT'
+      ;;
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	 lt_cv_prog_cc_pic=-Kconform_pic
+      fi
+      ;;
+    *)
+      lt_cv_prog_cc_pic='-fPIC'
+      ;;
+    esac
+  else
+    # PORTME Check for PIC flags for the system compiler.
+    case $host_os in
+    aix3* | aix4* | aix5*)
+      lt_cv_prog_cc_wl='-Wl,'
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	lt_cv_prog_cc_static='-Bstatic'
+      else
+	lt_cv_prog_cc_static='-bnso -bI:/lib/syscalls.exp'
+      fi
+      ;;
+
+    hpux9* | hpux10* | hpux11*)
+      # Is there a better lt_cv_prog_cc_static that works with the bundled CC?
+      lt_cv_prog_cc_wl='-Wl,'
+      lt_cv_prog_cc_static="${lt_cv_prog_cc_wl}-a ${lt_cv_prog_cc_wl}archive"
+      lt_cv_prog_cc_pic='+Z'
+      ;;
+
+    irix5* | irix6* | nonstopux*)
+      lt_cv_prog_cc_wl='-Wl,'
+      lt_cv_prog_cc_static='-non_shared'
+      # PIC (with -KPIC) is the default.
+      ;;
+
+    cygwin* | mingw* | pw32* | os2*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      lt_cv_prog_cc_pic='-DDLL_EXPORT'
+      ;;
+
+    newsos6)
+      lt_cv_prog_cc_pic='-KPIC'
+      lt_cv_prog_cc_static='-Bstatic'
+      ;;
+
+    osf3* | osf4* | osf5*)
+      # All OSF/1 code is PIC.
+      lt_cv_prog_cc_wl='-Wl,'
+      lt_cv_prog_cc_static='-non_shared'
+      ;;
+
+    sco3.2v5*)
+      lt_cv_prog_cc_pic='-Kpic'
+      lt_cv_prog_cc_static='-dn'
+      lt_cv_prog_cc_shlib='-belf'
+      ;;
+
+    solaris*)
+      lt_cv_prog_cc_pic='-KPIC'
+      lt_cv_prog_cc_static='-Bstatic'
+      lt_cv_prog_cc_wl='-Wl,'
+      ;;
+
+    sunos4*)
+      lt_cv_prog_cc_pic='-PIC'
+      lt_cv_prog_cc_static='-Bstatic'
+      lt_cv_prog_cc_wl='-Qoption ld '
+      ;;
+
+    sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+      lt_cv_prog_cc_pic='-KPIC'
+      lt_cv_prog_cc_static='-Bstatic'
+      lt_cv_prog_cc_wl='-Wl,'
+      ;;
+
+    uts4*)
+      lt_cv_prog_cc_pic='-pic'
+      lt_cv_prog_cc_static='-Bstatic'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec ;then
+	lt_cv_prog_cc_pic='-Kconform_pic'
+	lt_cv_prog_cc_static='-Bstatic'
+      fi
+      ;;
+
+    *)
+      lt_cv_prog_cc_can_build_shared=no
+      ;;
+    esac
+  fi
+])
+if test -z "$lt_cv_prog_cc_pic"; then
+  AC_MSG_RESULT([none])
+else
+  AC_MSG_RESULT([$lt_cv_prog_cc_pic])
+
+  # Check to make sure the pic_flag actually works.
+  AC_MSG_CHECKING([if $compiler PIC flag $lt_cv_prog_cc_pic works])
+  AC_CACHE_VAL(lt_cv_prog_cc_pic_works, [dnl
+    save_CFLAGS="$CFLAGS"
+    CFLAGS="$CFLAGS $lt_cv_prog_cc_pic -DPIC"
+    AC_TRY_COMPILE([], [], [dnl
+      case $host_os in
+      hpux9* | hpux10* | hpux11*)
+	# On HP-UX, both CC and GCC only warn that PIC is supported... then
+	# they create non-PIC objects.  So, if there were any warnings, we
+	# assume that PIC is not supported.
+	if test -s conftest.err; then
+	  lt_cv_prog_cc_pic_works=no
+	else
+	  lt_cv_prog_cc_pic_works=yes
+	fi
+	;;
+      *)
+	lt_cv_prog_cc_pic_works=yes
+	;;
+      esac
+    ], [dnl
+      lt_cv_prog_cc_pic_works=no
+    ])
+    CFLAGS="$save_CFLAGS"
+  ])
+
+  if test "X$lt_cv_prog_cc_pic_works" = Xno; then
+    lt_cv_prog_cc_pic=
+    lt_cv_prog_cc_can_build_shared=no
+  else
+    lt_cv_prog_cc_pic=" $lt_cv_prog_cc_pic"
+  fi
+
+  AC_MSG_RESULT([$lt_cv_prog_cc_pic_works])
+fi
+
+# Check for any special shared library compilation flags.
+if test -n "$lt_cv_prog_cc_shlib"; then
+  AC_MSG_WARN([\`$CC' requires \`$lt_cv_prog_cc_shlib' to build shared libraries])
+  if echo "$old_CC $old_CFLAGS " | egrep -e "[[ 	]]$lt_cv_prog_cc_shlib[[ 	]]" >/dev/null; then :
+  else
+   AC_MSG_WARN([add \`$lt_cv_prog_cc_shlib' to the CC or CFLAGS env variable and reconfigure])
+    lt_cv_prog_cc_can_build_shared=no
+  fi
+fi
+
+AC_MSG_CHECKING([if $compiler static flag $lt_cv_prog_cc_static works])
+AC_CACHE_VAL([lt_cv_prog_cc_static_works], [dnl
+  lt_cv_prog_cc_static_works=no
+  save_LDFLAGS="$LDFLAGS"
+  LDFLAGS="$LDFLAGS $lt_cv_prog_cc_static"
+  AC_TRY_LINK([], [], [lt_cv_prog_cc_static_works=yes])
+  LDFLAGS="$save_LDFLAGS"
+])
+
+# Belt *and* braces to stop my trousers falling down:
+test "X$lt_cv_prog_cc_static_works" = Xno && lt_cv_prog_cc_static=
+AC_MSG_RESULT([$lt_cv_prog_cc_static_works])
+
+pic_flag="$lt_cv_prog_cc_pic"
+special_shlib_compile_flags="$lt_cv_prog_cc_shlib"
+wl="$lt_cv_prog_cc_wl"
+link_static_flag="$lt_cv_prog_cc_static"
+no_builtin_flag="$lt_cv_prog_cc_no_builtin"
+can_build_shared="$lt_cv_prog_cc_can_build_shared"
+
+
+# Check to see if options -o and -c are simultaneously supported by compiler
+AC_MSG_CHECKING([if $compiler supports -c -o file.$ac_objext])
+AC_CACHE_VAL([lt_cv_compiler_c_o], [
+$rm -r conftest 2>/dev/null
+mkdir conftest
+cd conftest
+echo "int some_variable = 0;" > conftest.$ac_ext
+mkdir out
+# According to Tom Tromey, Ian Lance Taylor reported there are C compilers
+# that will create temporary files in the current directory regardless of
+# the output directory.  Thus, making CWD read-only will cause this test
+# to fail, enabling locking or at least warning the user not to do parallel
+# builds.
+chmod -w .
+save_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -o out/conftest2.$ac_objext"
+compiler_c_o=no
+if { (eval echo configure:__oline__: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then
+  # The compiler can only warn and ignore the option if not recognized
+  # So say no if there are warnings
+  if test -s out/conftest.err; then
+    lt_cv_compiler_c_o=no
+  else
+    lt_cv_compiler_c_o=yes
+  fi
+else
+  # Append any errors to the config.log.
+  cat out/conftest.err 1>&AC_FD_CC
+  lt_cv_compiler_c_o=no
+fi
+CFLAGS="$save_CFLAGS"
+chmod u+w .
+$rm conftest* out/*
+rmdir out
+cd ..
+rmdir conftest
+$rm -r conftest 2>/dev/null
+])
+compiler_c_o=$lt_cv_compiler_c_o
+AC_MSG_RESULT([$compiler_c_o])
+
+if test x"$compiler_c_o" = x"yes"; then
+  # Check to see if we can write to a .lo
+  AC_MSG_CHECKING([if $compiler supports -c -o file.lo])
+  AC_CACHE_VAL([lt_cv_compiler_o_lo], [
+  lt_cv_compiler_o_lo=no
+  save_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -c -o conftest.lo"
+  save_objext="$ac_objext"
+  ac_objext=lo
+  AC_TRY_COMPILE([], [int some_variable = 0;], [dnl
+    # The compiler can only warn and ignore the option if not recognized
+    # So say no if there are warnings
+    if test -s conftest.err; then
+      lt_cv_compiler_o_lo=no
+    else
+      lt_cv_compiler_o_lo=yes
+    fi
+  ])
+  ac_objext="$save_objext"
+  CFLAGS="$save_CFLAGS"
+  ])
+  compiler_o_lo=$lt_cv_compiler_o_lo
+  AC_MSG_RESULT([$compiler_o_lo])
+else
+  compiler_o_lo=no
+fi
+
+# Check to see if we can do hard links to lock some files if needed
+hard_links="nottested"
+if test "$compiler_c_o" = no && test "$need_locks" != no; then
+  # do not overwrite the value of need_locks provided by the user
+  AC_MSG_CHECKING([if we can lock with hard links])
+  hard_links=yes
+  $rm conftest*
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  touch conftest.a
+  ln conftest.a conftest.b 2>&5 || hard_links=no
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  AC_MSG_RESULT([$hard_links])
+  if test "$hard_links" = no; then
+    AC_MSG_WARN([\`$CC' does not support \`-c -o', so \`make -j' may be unsafe])
+    need_locks=warn
+  fi
+else
+  need_locks=no
+fi
+
+if test "$GCC" = yes; then
+  # Check to see if options -fno-rtti -fno-exceptions are supported by compiler
+  AC_MSG_CHECKING([if $compiler supports -fno-rtti -fno-exceptions])
+  echo "int some_variable = 0;" > conftest.$ac_ext
+  save_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -fno-rtti -fno-exceptions -c conftest.$ac_ext"
+  compiler_rtti_exceptions=no
+  AC_TRY_COMPILE([], [int some_variable = 0;], [dnl
+    # The compiler can only warn and ignore the option if not recognized
+    # So say no if there are warnings
+    if test -s conftest.err; then
+      compiler_rtti_exceptions=no
+    else
+      compiler_rtti_exceptions=yes
+    fi
+  ])
+  CFLAGS="$save_CFLAGS"
+  AC_MSG_RESULT([$compiler_rtti_exceptions])
+
+  if test "$compiler_rtti_exceptions" = "yes"; then
+    no_builtin_flag=' -fno-builtin -fno-rtti -fno-exceptions'
+  else
+    no_builtin_flag=' -fno-builtin'
+  fi
+fi
+
+# See if the linker supports building shared libraries.
+AC_MSG_CHECKING([whether the linker ($LD) supports shared libraries])
+
+allow_undefined_flag=
+no_undefined_flag=
+need_lib_prefix=unknown
+need_version=unknown
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+archive_cmds=
+archive_expsym_cmds=
+old_archive_from_new_cmds=
+old_archive_from_expsyms_cmds=
+export_dynamic_flag_spec=
+whole_archive_flag_spec=
+thread_safe_flag_spec=
+hardcode_into_libs=no
+hardcode_libdir_flag_spec=
+hardcode_libdir_separator=
+hardcode_direct=no
+hardcode_minus_L=no
+hardcode_shlibpath_var=unsupported
+runpath_var=
+link_all_deplibs=unknown
+always_export_symbols=no
+export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | sed '\''s/.* //'\'' | sort | uniq > $export_symbols'
+# include_expsyms should be a list of space-separated symbols to be *always*
+# included in the symbol list
+include_expsyms=
+# exclude_expsyms can be an egrep regular expression of symbols to exclude
+# it will be wrapped by ` (' and `)$', so one must not match beginning or
+# end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+# as well as any symbol that contains `d'.
+exclude_expsyms="_GLOBAL_OFFSET_TABLE_"
+# Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+# platforms (ab)use it in PIC code, but their linkers get confused if
+# the symbol is explicitly referenced.  Since portable code cannot
+# rely on this symbol name, it's probably fine to never include it in
+# preloaded symbol tables.
+extract_expsyms_cmds=
+
+case $host_os in
+cygwin* | mingw* | pw32*)
+  # FIXME: the MSVC++ port hasn't been tested in a loooong time
+  # When not using gcc, we currently assume that we are using
+  # Microsoft Visual C++.
+  if test "$GCC" != yes; then
+    with_gnu_ld=no
+  fi
+  ;;
+openbsd*)
+  with_gnu_ld=no
+  ;;
+esac
+
+ld_shlibs=yes
+if test "$with_gnu_ld" = yes; then
+  # If archive_cmds runs LD, not CC, wlarc should be empty
+  wlarc='${wl}'
+
+  # See if GNU ld supports shared libraries.
+  case $host_os in
+  aix3* | aix4* | aix5*)
+    # On AIX, the GNU linker is very broken
+    # Note:Check GNU linker on AIX 5-IA64 when/if it becomes available.
+    ld_shlibs=no
+    cat <<EOF 1>&2
+
+*** Warning: the GNU linker, at least up to release 2.9.1, is reported
+*** to be unable to reliably create shared libraries on AIX.
+*** Therefore, libtool is disabling shared libraries support.  If you
+*** really care for shared libraries, you may want to modify your PATH
+*** so that a non-GNU linker is found, and then restart.
+
+EOF
+    ;;
+
+  amigaos*)
+    archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+    hardcode_libdir_flag_spec='-L$libdir'
+    hardcode_minus_L=yes
+
+    # Samuel A. Falvo II <kc5tja at dolphin.openprojects.net> reports
+    # that the semantics of dynamic libraries on AmigaOS, at least up
+    # to version 4, is to share data among multiple programs linked
+    # with the same dynamic library.  Since this doesn't match the
+    # behavior of shared libraries on other platforms, we can use
+    # them.
+    ld_shlibs=no
+    ;;
+
+  beos*)
+    if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
+      allow_undefined_flag=unsupported
+      # Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
+      # support --undefined.  This deserves some investigation.  FIXME
+      archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+    else
+      ld_shlibs=no
+    fi
+    ;;
+
+  cygwin* | mingw* | pw32*)
+    # hardcode_libdir_flag_spec is actually meaningless, as there is
+    # no search path for DLLs.
+    hardcode_libdir_flag_spec='-L$libdir'
+    allow_undefined_flag=unsupported
+    always_export_symbols=yes
+
+    extract_expsyms_cmds='test -f $output_objdir/impgen.c || \
+      sed -e "/^# \/\* impgen\.c starts here \*\//,/^# \/\* impgen.c ends here \*\// { s/^# //;s/^# *$//; p; }" -e d < $''0 > $output_objdir/impgen.c~
+      test -f $output_objdir/impgen.exe || (cd $output_objdir && \
+      if test "x$HOST_CC" != "x" ; then $HOST_CC -o impgen impgen.c ; \
+      else $CC -o impgen impgen.c ; fi)~
+      $output_objdir/impgen $dir/$soroot > $output_objdir/$soname-def'
+
+    old_archive_from_expsyms_cmds='$DLLTOOL --as=$AS --dllname $soname --def $output_objdir/$soname-def --output-lib $output_objdir/$newlib'
+
+    # cygwin and mingw dlls have different entry points and sets of symbols
+    # to exclude.
+    # FIXME: what about values for MSVC?
+    dll_entry=__cygwin_dll_entry at 12
+    dll_exclude_symbols=DllMain at 12,_cygwin_dll_entry at 12,_cygwin_noncygwin_dll_entry at 12~
+    case $host_os in
+    mingw*)
+      # mingw values
+      dll_entry=_DllMainCRTStartup at 12
+      dll_exclude_symbols=DllMain at 12,DllMainCRTStartup at 12,DllEntryPoint at 12~
+      ;;
+    esac
+
+    # mingw and cygwin differ, and it's simplest to just exclude the union
+    # of the two symbol sets.
+    dll_exclude_symbols=DllMain at 12,_cygwin_dll_entry at 12,_cygwin_noncygwin_dll_entry at 12,DllMainCRTStartup at 12,DllEntryPoint at 12
+
+    # recent cygwin and mingw systems supply a stub DllMain which the user
+    # can override, but on older systems we have to supply one (in ltdll.c)
+    if test "x$lt_cv_need_dllmain" = "xyes"; then
+      ltdll_obj='$output_objdir/$soname-ltdll.'"$ac_objext "
+      ltdll_cmds='test -f $output_objdir/$soname-ltdll.c || sed -e "/^# \/\* ltdll\.c starts here \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d < $''0 > $output_objdir/$soname-ltdll.c~
+	test -f $output_objdir/$soname-ltdll.$ac_objext || (cd $output_objdir && $CC -c $soname-ltdll.c)~'
+    else
+      ltdll_obj=
+      ltdll_cmds=
+    fi
+
+    # Extract the symbol export list from an `--export-all' def file,
+    # then regenerate the def file from the symbol export list, so that
+    # the compiled dll only exports the symbol export list.
+    # Be careful not to strip the DATA tag left be newer dlltools.
+    export_symbols_cmds="$ltdll_cmds"'
+      $DLLTOOL --export-all --exclude-symbols '$dll_exclude_symbols' --output-def $output_objdir/$soname-def '$ltdll_obj'$libobjs $convenience~
+      sed -e "1,/EXPORTS/d" -e "s/ @ [[0-9]]*//" -e "s/ *;.*$//" < $output_objdir/$soname-def > $export_symbols'
+
+    # If the export-symbols file already is a .def file (1st line
+    # is EXPORTS), use it as is.
+    # If DATA tags from a recent dlltool are present, honour them!
+    archive_expsym_cmds='if test "x`sed 1q $export_symbols`" = xEXPORTS; then
+	cp $export_symbols $output_objdir/$soname-def;
+      else
+	echo EXPORTS > $output_objdir/$soname-def;
+	_lt_hint=1;
+	cat $export_symbols | while read symbol; do
+	 set dummy \$symbol;
+	 case \[$]# in
+	   2) echo "   \[$]2 @ \$_lt_hint ; " >> $output_objdir/$soname-def;;
+	   4) echo "   \[$]2 \[$]3 \[$]4 ; " >> $output_objdir/$soname-def; _lt_hint=`expr \$_lt_hint - 1`;;
+	   *) echo "     \[$]2 @ \$_lt_hint \[$]3 ; " >> $output_objdir/$soname-def;;
+	 esac;
+	 _lt_hint=`expr 1 + \$_lt_hint`;
+	done;
+      fi~
+      '"$ltdll_cmds"'
+      $CC -Wl,--base-file,$output_objdir/$soname-base '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $output_objdir/$soname '$ltdll_obj'$libobjs $deplibs $compiler_flags~
+      $DLLTOOL --as=$AS --dllname $soname --exclude-symbols '$dll_exclude_symbols' --def $output_objdir/$soname-def --base-file $output_objdir/$soname-base --output-exp $output_objdir/$soname-exp~
+      $CC -Wl,--base-file,$output_objdir/$soname-base $output_objdir/$soname-exp '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $output_objdir/$soname '$ltdll_obj'$libobjs $deplibs $compiler_flags~
+      $DLLTOOL --as=$AS --dllname $soname --exclude-symbols '$dll_exclude_symbols' --def $output_objdir/$soname-def --base-file $output_objdir/$soname-base --output-exp $output_objdir/$soname-exp --output-lib $output_objdir/$libname.dll.a~
+      $CC $output_objdir/$soname-exp '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $output_objdir/$soname '$ltdll_obj'$libobjs $deplibs $compiler_flags'
+    ;;
+
+  netbsd*)
+    if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+      archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+      wlarc=
+    else
+      archive_cmds='$CC -shared -nodefaultlibs $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      archive_expsym_cmds='$CC -shared -nodefaultlibs $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+    fi
+    ;;
+
+  solaris* | sysv5*)
+    if $LD -v 2>&1 | egrep 'BFD 2\.8' > /dev/null; then
+      ld_shlibs=no
+      cat <<EOF 1>&2
+
+*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+*** create shared libraries on Solaris systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.9.1 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+EOF
+    elif $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
+      archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+    else
+      ld_shlibs=no
+    fi
+    ;;
+
+  sunos4*)
+    archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+    wlarc=
+    hardcode_direct=yes
+    hardcode_shlibpath_var=no
+    ;;
+
+  *)
+    if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
+      archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+    else
+      ld_shlibs=no
+    fi
+    ;;
+  esac
+
+  if test "$ld_shlibs" = yes; then
+    runpath_var=LD_RUN_PATH
+    hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir'
+    export_dynamic_flag_spec='${wl}--export-dynamic'
+    case $host_os in
+    cygwin* | mingw* | pw32*)
+      # dlltool doesn't understand --whole-archive et. al.
+      whole_archive_flag_spec=
+      ;;
+    *)
+      # ancient GNU ld didn't support --whole-archive et. al.
+      if $LD --help 2>&1 | egrep 'no-whole-archive' > /dev/null; then
+	whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      else
+	whole_archive_flag_spec=
+      fi
+      ;;
+    esac
+  fi
+else
+  # PORTME fill in a description of your system's linker (not GNU ld)
+  case $host_os in
+  aix3*)
+    allow_undefined_flag=unsupported
+    always_export_symbols=yes
+    archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+    # Note: this linker hardcodes the directories in LIBPATH if there
+    # are no directories specified by -L.
+    hardcode_minus_L=yes
+    if test "$GCC" = yes && test -z "$link_static_flag"; then
+      # Neither direct hardcoding nor static linking is supported with a
+      # broken collect2.
+      hardcode_direct=unsupported
+    fi
+    ;;
+
+  aix4* | aix5*)
+    if test "$host_cpu" = ia64; then
+      # On IA64, the linker does run time linking by default, so we don't
+      # have to do anything special.
+      aix_use_runtimelinking=no
+      exp_sym_flag='-Bexport'
+      no_entry_flag=""
+    else
+      aix_use_runtimelinking=no
+
+      # Test if we are trying to use run time linking or normal
+      # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+      # need to do runtime linking.
+      case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*)
+	for ld_flag in $LDFLAGS; do
+	  case $ld_flag in
+	  *-brtl*)
+	    aix_use_runtimelinking=yes
+	    break
+	  ;;
+	  esac
+	done
+      esac
+
+      exp_sym_flag='-bexport'
+      no_entry_flag='-bnoentry'
+    fi
+
+    # When large executables or shared objects are built, AIX ld can
+    # have problems creating the table of contents.  If linking a library
+    # or program results in "error TOC overflow" add -mminimal-toc to
+    # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
+    # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+    hardcode_direct=yes
+    archive_cmds=''
+    hardcode_libdir_separator=':'
+    if test "$GCC" = yes; then
+      case $host_os in aix4.[[012]]|aix4.[[012]].*)
+	collect2name=`${CC} -print-prog-name=collect2`
+	if test -f "$collect2name" && \
+	  strings "$collect2name" | grep resolve_lib_name >/dev/null
+	then
+	  # We have reworked collect2
+	  hardcode_direct=yes
+	else
+	  # We have old collect2
+	  hardcode_direct=unsupported
+	  # It fails to find uninstalled libraries when the uninstalled
+	  # path is not listed in the libpath.  Setting hardcode_minus_L
+	  # to unsupported forces relinking
+	  hardcode_minus_L=yes
+	  hardcode_libdir_flag_spec='-L$libdir'
+	  hardcode_libdir_separator=
+	fi
+      esac
+
+      shared_flag='-shared'
+    else
+      # not using gcc
+      if test "$host_cpu" = ia64; then
+	shared_flag='${wl}-G'
+      else
+	if test "$aix_use_runtimelinking" = yes; then
+	  shared_flag='${wl}-G'
+	else
+	  shared_flag='${wl}-bM:SRE'
+	fi
+      fi
+    fi
+
+    # It seems that -bexpall can do strange things, so it is better to
+    # generate a list of symbols to export.
+    always_export_symbols=yes
+    if test "$aix_use_runtimelinking" = yes; then
+      # Warning - without using the other runtime loading flags (-brtl),
+      # -berok will link without error, but may produce a broken library.
+      allow_undefined_flag='-berok'
+      hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:/usr/lib:/lib'
+      archive_expsym_cmds="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+    else
+      if test "$host_cpu" = ia64; then
+	hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
+	allow_undefined_flag="-z nodefs"
+	archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname ${wl}-h$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"
+      else
+	hardcode_libdir_flag_spec='${wl}-bnolibpath ${wl}-blibpath:$libdir:/usr/lib:/lib'
+	# Warning - without using the other run time loading flags,
+	# -berok will link without error, but may produce a broken library.
+	allow_undefined_flag='${wl}-berok'
+	# This is a bit strange, but is similar to how AIX traditionally builds
+	# it's shared libraries.
+	archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"' ~$AR -crlo $objdir/$libname$release.a $objdir/$soname'
+      fi
+    fi
+    ;;
+
+  amigaos*)
+    archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+    hardcode_libdir_flag_spec='-L$libdir'
+    hardcode_minus_L=yes
+    # see comment about different semantics on the GNU ld section
+    ld_shlibs=no
+    ;;
+
+  cygwin* | mingw* | pw32*)
+    # When not using gcc, we currently assume that we are using
+    # Microsoft Visual C++.
+    # hardcode_libdir_flag_spec is actually meaningless, as there is
+    # no search path for DLLs.
+    hardcode_libdir_flag_spec=' '
+    allow_undefined_flag=unsupported
+    # Tell ltmain to make .lib files, not .a files.
+    libext=lib
+    # FIXME: Setting linknames here is a bad hack.
+    archive_cmds='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | sed -e '\''s/ -lc$//'\''` -link -dll~linknames='
+    # The linker will automatically build a .lib file if we build a DLL.
+    old_archive_from_new_cmds='true'
+    # FIXME: Should let the user specify the lib program.
+    old_archive_cmds='lib /OUT:$oldlib$oldobjs$old_deplibs'
+    fix_srcfile_path='`cygpath -w "$srcfile"`'
+    ;;
+
+  darwin* | rhapsody*)
+    case "$host_os" in
+    rhapsody* | darwin1.[[012]])
+      allow_undefined_flag='-undefined suppress'
+      ;;
+    *) # Darwin 1.3 on
+      allow_undefined_flag='-flat_namespace -undefined suppress'
+      ;;
+    esac
+    # FIXME: Relying on posixy $() will cause problems for
+    #        cross-compilation, but unfortunately the echo tests do not
+    #        yet detect zsh echo's removal of \ escapes.  Also zsh mangles
+    #	     `"' quotes if we put them in here... so don't!
+    archive_cmds='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs && $CC $(test .$module = .yes && echo -bundle || echo -dynamiclib) $allow_undefined_flag -o $lib ${lib}-master.o $deplibs$linker_flags $(test .$module != .yes && echo -install_name $rpath/$soname $verstring)'
+    # We need to add '_' to the symbols in $export_symbols first
+    #archive_expsym_cmds="$archive_cmds"' && strip -s $export_symbols'
+    hardcode_direct=yes
+    hardcode_shlibpath_var=no
+    whole_archive_flag_spec='-all_load $convenience'
+    ;;
+
+  freebsd1*)
+    ld_shlibs=no
+    ;;
+
+  # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+  # support.  Future versions do this automatically, but an explicit c++rt0.o
+  # does not break anything, and helps significantly (at the cost of a little
+  # extra space).
+  freebsd2.2*)
+    archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+    hardcode_libdir_flag_spec='-R$libdir'
+    hardcode_direct=yes
+    hardcode_shlibpath_var=no
+    ;;
+
+  # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+  freebsd2*)
+    archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+    hardcode_direct=yes
+    hardcode_minus_L=yes
+    hardcode_shlibpath_var=no
+    ;;
+
+  # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+  freebsd*)
+    archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
+    hardcode_libdir_flag_spec='-R$libdir'
+    hardcode_direct=yes
+    hardcode_shlibpath_var=no
+    ;;
+
+  hpux9* | hpux10* | hpux11*)
+    case $host_os in
+    hpux9*) archive_cmds='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' ;;
+    *) archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' ;;
+    esac
+    hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+    hardcode_libdir_separator=:
+    hardcode_direct=yes
+    hardcode_minus_L=yes # Not in the search PATH, but as the default
+			 # location of the library.
+    export_dynamic_flag_spec='${wl}-E'
+    ;;
+
+  irix5* | irix6* | nonstopux*)
+    if test "$GCC" = yes; then
+      archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+    else
+      archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+      hardcode_libdir_flag_spec='-rpath $libdir'
+    fi
+    hardcode_libdir_separator=:
+    link_all_deplibs=yes
+    ;;
+
+  netbsd*)
+    if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+      archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
+    else
+      archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
+    fi
+    hardcode_libdir_flag_spec='-R$libdir'
+    hardcode_direct=yes
+    hardcode_shlibpath_var=no
+    ;;
+
+  newsos6)
+    archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+    hardcode_direct=yes
+    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+    hardcode_libdir_separator=:
+    hardcode_shlibpath_var=no
+    ;;
+
+  openbsd*)
+    hardcode_direct=yes
+    hardcode_shlibpath_var=no
+    if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+      archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+      hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+      export_dynamic_flag_spec='${wl}-E'
+    else
+      case "$host_os" in
+      openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
+	archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+	hardcode_libdir_flag_spec='-R$libdir'
+        ;;
+      *)
+        archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+        hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+        ;;
+      esac
+    fi
+    ;;
+
+  os2*)
+    hardcode_libdir_flag_spec='-L$libdir'
+    hardcode_minus_L=yes
+    allow_undefined_flag=unsupported
+    archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+    old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+    ;;
+
+  osf3*)
+    if test "$GCC" = yes; then
+      allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
+      archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+    else
+      allow_undefined_flag=' -expect_unresolved \*'
+      archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+    fi
+    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+    hardcode_libdir_separator=:
+    ;;
+
+  osf4* | osf5*)	# as osf3* with the addition of -msym flag
+    if test "$GCC" = yes; then
+      allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
+      archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+    else
+      allow_undefined_flag=' -expect_unresolved \*'
+      archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+      archive_expsym_cmds='for i in `cat $export_symbols`; do printf "-exported_symbol " >> $lib.exp; echo "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
+      $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib~$rm $lib.exp'
+
+      #Both c and cxx compiler support -rpath directly
+      hardcode_libdir_flag_spec='-rpath $libdir'
+    fi
+    hardcode_libdir_separator=:
+    ;;
+
+  sco3.2v5*)
+    archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+    hardcode_shlibpath_var=no
+    runpath_var=LD_RUN_PATH
+    hardcode_runpath_var=yes
+    export_dynamic_flag_spec='${wl}-Bexport'
+    ;;
+
+  solaris*)
+    # gcc --version < 3.0 without binutils cannot create self contained
+    # shared libraries reliably, requiring libgcc.a to resolve some of
+    # the object symbols generated in some cases.  Libraries that use
+    # assert need libgcc.a to resolve __eprintf, for example.  Linking
+    # a copy of libgcc.a into every shared library to guarantee resolving
+    # such symbols causes other problems:  According to Tim Van Holder
+    # <tim.van.holder at pandora.be>, C++ libraries end up with a separate
+    # (to the application) exception stack for one thing.
+    no_undefined_flag=' -z defs'
+    if test "$GCC" = yes; then
+      case `$CC --version 2>/dev/null` in
+      [[12]].*)
+	cat <<EOF 1>&2
+
+*** Warning: Releases of GCC earlier than version 3.0 cannot reliably
+*** create self contained shared libraries on Solaris systems, without
+*** introducing a dependency on libgcc.a.  Therefore, libtool is disabling
+*** -no-undefined support, which will at least allow you to build shared
+*** libraries.  However, you may find that when you link such libraries
+*** into an application without using GCC, you have to manually add
+*** \`gcc --print-libgcc-file-name\` to the link command.  We urge you to
+*** upgrade to a newer version of GCC.  Another option is to rebuild your
+*** current GCC to use the GNU linker from GNU binutils 2.9.1 or newer.
+
+EOF
+        no_undefined_flag=
+	;;
+      esac
+    fi
+    # $CC -shared without GNU ld will not create a library from C++
+    # object files and a static libstdc++, better avoid it by now
+    archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+    archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+		$LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
+    hardcode_libdir_flag_spec='-R$libdir'
+    hardcode_shlibpath_var=no
+    case $host_os in
+    solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+    *) # Supported since Solaris 2.6 (maybe 2.5.1?)
+      whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;;
+    esac
+    link_all_deplibs=yes
+    ;;
+
+  sunos4*)
+    if test "x$host_vendor" = xsequent; then
+      # Use $CC to link under sequent, because it throws in some extra .o
+      # files that make .init and .fini sections work.
+      archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+    else
+      archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+    fi
+    hardcode_libdir_flag_spec='-L$libdir'
+    hardcode_direct=yes
+    hardcode_minus_L=yes
+    hardcode_shlibpath_var=no
+    ;;
+
+  sysv4)
+    case $host_vendor in
+      sni)
+        archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+        hardcode_direct=yes # is this really true???
+        ;;
+      siemens)
+        ## LD is ld it makes a PLAMLIB
+        ## CC just makes a GrossModule.
+        archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+        reload_cmds='$CC -r -o $output$reload_objs'
+        hardcode_direct=no
+        ;;
+      motorola)
+        archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+        hardcode_direct=no #Motorola manual says yes, but my tests say they lie
+        ;;
+    esac
+    runpath_var='LD_RUN_PATH'
+    hardcode_shlibpath_var=no
+    ;;
+
+  sysv4.3*)
+    archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+    hardcode_shlibpath_var=no
+    export_dynamic_flag_spec='-Bexport'
+    ;;
+
+  sysv5*)
+    no_undefined_flag=' -z text'
+    # $CC -shared without GNU ld will not create a library from C++
+    # object files and a static libstdc++, better avoid it by now
+    archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+    archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+		$LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
+    hardcode_libdir_flag_spec=
+    hardcode_shlibpath_var=no
+    runpath_var='LD_RUN_PATH'
+    ;;
+
+  uts4*)
+    archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+    hardcode_libdir_flag_spec='-L$libdir'
+    hardcode_shlibpath_var=no
+    ;;
+
+  dgux*)
+    archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+    hardcode_libdir_flag_spec='-L$libdir'
+    hardcode_shlibpath_var=no
+    ;;
+
+  sysv4*MP*)
+    if test -d /usr/nec; then
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_shlibpath_var=no
+      runpath_var=LD_RUN_PATH
+      hardcode_runpath_var=yes
+      ld_shlibs=yes
+    fi
+    ;;
+
+  sysv4.2uw2*)
+    archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+    hardcode_direct=yes
+    hardcode_minus_L=no
+    hardcode_shlibpath_var=no
+    hardcode_runpath_var=yes
+    runpath_var=LD_RUN_PATH
+    ;;
+
+  sysv5uw7* | unixware7*)
+    no_undefined_flag='${wl}-z ${wl}text'
+    if test "$GCC" = yes; then
+      archive_cmds='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+    else
+      archive_cmds='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+    fi
+    runpath_var='LD_RUN_PATH'
+    hardcode_shlibpath_var=no
+    ;;
+
+  *)
+    ld_shlibs=no
+    ;;
+  esac
+fi
+AC_MSG_RESULT([$ld_shlibs])
+test "$ld_shlibs" = no && can_build_shared=no
+
+# Check hardcoding attributes.
+AC_MSG_CHECKING([how to hardcode library paths into programs])
+hardcode_action=
+if test -n "$hardcode_libdir_flag_spec" || \
+   test -n "$runpath_var"; then
+
+  # We can hardcode non-existant directories.
+  if test "$hardcode_direct" != no &&
+     # If the only mechanism to avoid hardcoding is shlibpath_var, we
+     # have to relink, otherwise we might link with an installed library
+     # when we should be linking with a yet-to-be-installed one
+     ## test "$hardcode_shlibpath_var" != no &&
+     test "$hardcode_minus_L" != no; then
+    # Linking always hardcodes the temporary library directory.
+    hardcode_action=relink
+  else
+    # We can link without hardcoding, and we can hardcode nonexisting dirs.
+    hardcode_action=immediate
+  fi
+else
+  # We cannot hardcode anything, or else we can only hardcode existing
+  # directories.
+  hardcode_action=unsupported
+fi
+AC_MSG_RESULT([$hardcode_action])
+
+striplib=
+old_striplib=
+AC_MSG_CHECKING([whether stripping libraries is possible])
+if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then
+  test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+  test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+  AC_MSG_RESULT([yes])
+else
+  AC_MSG_RESULT([no])
+fi
+
+reload_cmds='$LD$reload_flag -o $output$reload_objs'
+test -z "$deplibs_check_method" && deplibs_check_method=unknown
+
+# PORTME Fill in your ld.so characteristics
+AC_MSG_CHECKING([dynamic linker characteristics])
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+
+case $host_os in
+aix3*)
+  version_type=linux
+  library_names_spec='${libname}${release}.so$versuffix $libname.a'
+  shlibpath_var=LIBPATH
+
+  # AIX has no versioning support, so we append a major version to the name.
+  soname_spec='${libname}${release}.so$major'
+  ;;
+
+aix4* | aix5*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  hardcode_into_libs=yes
+  if test "$host_cpu" = ia64; then
+    # AIX 5 supports IA64
+    library_names_spec='${libname}${release}.so$major ${libname}${release}.so$versuffix $libname.so'
+    shlibpath_var=LD_LIBRARY_PATH
+  else
+    # With GCC up to 2.95.x, collect2 would create an import file
+    # for dependence libraries.  The import file would start with
+    # the line `#! .'.  This would cause the generated library to
+    # depend on `.', always an invalid library.  This was fixed in
+    # development snapshots of GCC prior to 3.0.
+    case $host_os in
+      aix4 | aix4.[[01]] | aix4.[[01]].*)
+	if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+	     echo ' yes '
+	     echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
+	  :
+	else
+	  can_build_shared=no
+	fi
+	;;
+    esac
+    # AIX (on Power*) has no versioning support, so currently we can
+    # not hardcode correct soname into executable. Probably we can
+    # add versioning support to collect2, so additional links can
+    # be useful in future.
+    if test "$aix_use_runtimelinking" = yes; then
+      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+      # instead of lib<name>.a to let people know that these are not
+      # typical AIX shared libraries.
+      library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+    else
+      # We preserve .a as extension for shared libraries through AIX4.2
+      # and later when we are not doing run time linking.
+      library_names_spec='${libname}${release}.a $libname.a'
+      soname_spec='${libname}${release}.so$major'
+    fi
+    shlibpath_var=LIBPATH
+  fi
+  hardcode_into_libs=yes
+  ;;
+
+amigaos*)
+  library_names_spec='$libname.ixlibrary $libname.a'
+  # Create ${libname}_ixlibrary.a entries in /sys/libs.
+  finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "(cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a)"; (cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a) || exit 1; done'
+  ;;
+
+beos*)
+  library_names_spec='${libname}.so'
+  dynamic_linker="$host_os ld.so"
+  shlibpath_var=LIBRARY_PATH
+  ;;
+
+bsdi4*)
+  version_type=linux
+  need_version=no
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+  soname_spec='${libname}${release}.so$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+  export_dynamic_flag_spec=-rdynamic
+  # the default ld.so.conf also contains /usr/contrib/lib and
+  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+  # libtool to hard-code these into programs
+  ;;
+
+cygwin* | mingw* | pw32*)
+  version_type=windows
+  need_version=no
+  need_lib_prefix=no
+  case $GCC,$host_os in
+  yes,cygwin*)
+    library_names_spec='$libname.dll.a'
+    soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | sed -e 's/[[.]]/-/g'`${versuffix}.dll'
+    postinstall_cmds='dlpath=`bash 2>&1 -c '\''. $dir/${file}i;echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog .libs/$dlname \$dldir/$dlname'
+    postuninstall_cmds='dldll=`bash 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $rm \$dlpath'
+    ;;
+  yes,mingw*)
+    library_names_spec='${libname}`echo ${release} | sed -e 's/[[.]]/-/g'`${versuffix}.dll'
+    sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | sed -e "s/^libraries://" -e "s/;/ /g" -e "s,=/,/,g"`
+    ;;
+  yes,pw32*)
+    library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll'
+    ;;
+  *)
+    library_names_spec='${libname}`echo ${release} | sed -e 's/[[.]]/-/g'`${versuffix}.dll $libname.lib'
+    ;;
+  esac
+  dynamic_linker='Win32 ld.exe'
+  # FIXME: first we should search . and the directory the executable is in
+  shlibpath_var=PATH
+  ;;
+
+darwin* | rhapsody*)
+  dynamic_linker="$host_os dyld"
+  version_type=darwin
+  need_lib_prefix=no
+  need_version=no
+  # FIXME: Relying on posixy $() will cause problems for
+  #        cross-compilation, but unfortunately the echo tests do not
+  #        yet detect zsh echo's removal of \ escapes.
+  library_names_spec='${libname}${release}${versuffix}.$(test .$module = .yes && echo so || echo dylib) ${libname}${release}${major}.$(test .$module = .yes && echo so || echo dylib) ${libname}.$(test .$module = .yes && echo so || echo dylib)'
+  soname_spec='${libname}${release}${major}.$(test .$module = .yes && echo so || echo dylib)'
+  shlibpath_overrides_runpath=yes
+  shlibpath_var=DYLD_LIBRARY_PATH
+  ;;
+
+freebsd1*)
+  dynamic_linker=no
+  ;;
+
+freebsd*)
+  objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
+  version_type=freebsd-$objformat
+  case $version_type in
+    freebsd-elf*)
+      library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so'
+      need_version=no
+      need_lib_prefix=no
+      ;;
+    freebsd-*)
+      library_names_spec='${libname}${release}.so$versuffix $libname.so$versuffix'
+      need_version=yes
+      ;;
+  esac
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_os in
+  freebsd2*)
+    shlibpath_overrides_runpath=yes
+    ;;
+  *)
+    shlibpath_overrides_runpath=no
+    hardcode_into_libs=yes
+    ;;
+  esac
+  ;;
+
+gnu*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so${major} ${libname}.so'
+  soname_spec='${libname}${release}.so$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  hardcode_into_libs=yes
+  ;;
+
+hpux9* | hpux10* | hpux11*)
+  # Give a soname corresponding to the major version so that dld.sl refuses to
+  # link against other versions.
+  dynamic_linker="$host_os dld.sl"
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  shlibpath_var=SHLIB_PATH
+  shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+  library_names_spec='${libname}${release}.sl$versuffix ${libname}${release}.sl$major $libname.sl'
+  soname_spec='${libname}${release}.sl$major'
+  # HP-UX runs *really* slowly unless shared libraries are mode 555.
+  postinstall_cmds='chmod 555 $lib'
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $host_os in
+    nonstopux*) version_type=nonstopux ;;
+    *)          version_type=irix ;;
+  esac
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}.so$major'
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major ${libname}${release}.so $libname.so'
+  case $host_os in
+  irix5* | nonstopux*)
+    libsuff= shlibsuff=
+    ;;
+  *)
+    case $LD in # libtool.m4 will add one of these switches to LD
+    *-32|*"-32 ") libsuff= shlibsuff= libmagic=32-bit;;
+    *-n32|*"-n32 ") libsuff=32 shlibsuff=N32 libmagic=N32;;
+    *-64|*"-64 ") libsuff=64 shlibsuff=64 libmagic=64-bit;;
+    *) libsuff= shlibsuff= libmagic=never-match;;
+    esac
+    ;;
+  esac
+  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+  shlibpath_overrides_runpath=no
+  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  ;;
+
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+  dynamic_linker=no
+  ;;
+
+# This must be Linux ELF.
+linux*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+  soname_spec='${libname}${release}.so$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
+
+  case $host_cpu:$lt_cv_cc_64bit_output in
+  powerpc64:yes | s390x:yes | sparc64:yes | x86_64:yes)
+    sys_lib_dlsearch_path_spec="/lib64 /usr/lib64"
+    sys_lib_search_path_spec="/lib64 /usr/lib64 /usr/local/lib64"
+    ;;
+  esac
+
+  # We used to test for /lib/ld.so.1 and disable shared libraries on
+  # powerpc, because MkLinux only supported shared libraries with the
+  # GNU dynamic linker.  Since this was broken with cross compilers,
+  # most powerpc-linux boxes support dynamic linking these days and
+  # people can always --disable-shared, the test was removed, and we
+  # assume the GNU/Linux dynamic linker is in use.
+  dynamic_linker='GNU/Linux ld.so'
+  ;;
+
+netbsd*)
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+    library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix'
+    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+    dynamic_linker='NetBSD (a.out) ld.so'
+  else
+    library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major ${libname}${release}.so ${libname}.so'
+    soname_spec='${libname}${release}.so$major'
+    dynamic_linker='NetBSD ld.elf_so'
+  fi
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  ;;
+
+newsos6)
+  version_type=linux
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+openbsd*)
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    case "$host_os" in
+    openbsd2.[[89]] | openbsd2.[[89]].*)
+      shlibpath_overrides_runpath=no
+      ;;
+    *)
+      shlibpath_overrides_runpath=yes
+      ;;
+    esac
+  else
+    shlibpath_overrides_runpath=yes
+  fi
+  library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+os2*)
+  libname_spec='$name'
+  need_lib_prefix=no
+  library_names_spec='$libname.dll $libname.a'
+  dynamic_linker='OS/2 ld.exe'
+  shlibpath_var=LIBPATH
+  ;;
+
+osf3* | osf4* | osf5*)
+  version_type=osf
+  need_version=no
+  soname_spec='${libname}${release}.so$major'
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  hardcode_into_libs=yes
+  ;;
+
+sco3.2v5*)
+  version_type=osf
+  soname_spec='${libname}${release}.so$major'
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+solaris*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+  soname_spec='${libname}${release}.so$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  # ldd complains unless libraries are executable
+  postinstall_cmds='chmod +x $lib'
+  ;;
+
+sunos4*)
+  version_type=sunos
+  library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix'
+  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  if test "$with_gnu_ld" = yes; then
+    need_lib_prefix=no
+  fi
+  need_version=yes
+  ;;
+
+sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+  version_type=linux
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+  soname_spec='${libname}${release}.so$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_vendor in
+    sni)
+      shlibpath_overrides_runpath=no
+      need_lib_prefix=no
+      export_dynamic_flag_spec='${wl}-Blargedynsym'
+      runpath_var=LD_RUN_PATH
+      ;;
+    siemens)
+      need_lib_prefix=no
+      ;;
+    motorola)
+      need_lib_prefix=no
+      need_version=no
+      shlibpath_overrides_runpath=no
+      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+      ;;
+  esac
+  ;;
+
+uts4*)
+  version_type=linux
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+  soname_spec='${libname}${release}.so$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+dgux*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+  soname_spec='${libname}${release}.so$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+sysv4*MP*)
+  if test -d /usr/nec ;then
+    version_type=linux
+    library_names_spec='$libname.so.$versuffix $libname.so.$major $libname.so'
+    soname_spec='$libname.so.$major'
+    shlibpath_var=LD_LIBRARY_PATH
+  fi
+  ;;
+
+*)
+  dynamic_linker=no
+  ;;
+esac
+AC_MSG_RESULT([$dynamic_linker])
+test "$dynamic_linker" = no && can_build_shared=no
+
+# Report the final consequences.
+AC_MSG_CHECKING([if libtool supports shared libraries])
+AC_MSG_RESULT([$can_build_shared])
+
+AC_MSG_CHECKING([whether to build shared libraries])
+test "$can_build_shared" = "no" && enable_shared=no
+
+# On AIX, shared libraries and static libraries use the same namespace, and
+# are all built from PIC.
+case "$host_os" in
+aix3*)
+  test "$enable_shared" = yes && enable_static=no
+  if test -n "$RANLIB"; then
+    archive_cmds="$archive_cmds~\$RANLIB \$lib"
+    postinstall_cmds='$RANLIB $lib'
+  fi
+  ;;
+
+aix4*)
+  if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+    test "$enable_shared" = yes && enable_static=no
+  fi
+  ;;
+esac
+AC_MSG_RESULT([$enable_shared])
+
+AC_MSG_CHECKING([whether to build static libraries])
+# Make sure either enable_shared or enable_static is yes.
+test "$enable_shared" = yes || enable_static=yes
+AC_MSG_RESULT([$enable_static])
+
+if test "$hardcode_action" = relink; then
+  # Fast installation is not supported
+  enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+     test "$enable_shared" = no; then
+  # Fast installation is not necessary
+  enable_fast_install=needless
+fi
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+
+AC_LIBTOOL_DLOPEN_SELF
+
+if test "$enable_shared" = yes && test "$GCC" = yes; then
+  case $archive_cmds in
+  *'~'*)
+    # FIXME: we may have to deal with multi-command sequences.
+    ;;
+  '$CC '*)
+    # Test whether the compiler implicitly links with -lc since on some
+    # systems, -lgcc has to come before -lc. If gcc already passes -lc
+    # to ld, don't add -lc before -lgcc.
+    AC_MSG_CHECKING([whether -lc should be explicitly linked in])
+    AC_CACHE_VAL([lt_cv_archive_cmds_need_lc],
+    [$rm conftest*
+    echo 'static int dummy;' > conftest.$ac_ext
+
+    if AC_TRY_EVAL(ac_compile); then
+      soname=conftest
+      lib=conftest
+      libobjs=conftest.$ac_objext
+      deplibs=
+      wl=$lt_cv_prog_cc_wl
+      compiler_flags=-v
+      linker_flags=-v
+      verstring=
+      output_objdir=.
+      libname=conftest
+      save_allow_undefined_flag=$allow_undefined_flag
+      allow_undefined_flag=
+      if AC_TRY_EVAL(archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1)
+      then
+	lt_cv_archive_cmds_need_lc=no
+      else
+	lt_cv_archive_cmds_need_lc=yes
+      fi
+      allow_undefined_flag=$save_allow_undefined_flag
+    else
+      cat conftest.err 1>&5
+    fi])
+    AC_MSG_RESULT([$lt_cv_archive_cmds_need_lc])
+    ;;
+  esac
+fi
+need_lc=${lt_cv_archive_cmds_need_lc-yes}
+
+# The second clause should only fire when bootstrapping the
+# libtool distribution, otherwise you forgot to ship ltmain.sh
+# with your package, and you will get complaints that there are
+# no rules to generate ltmain.sh.
+if test -f "$ltmain"; then
+  :
+else
+  # If there is no Makefile yet, we rely on a make rule to execute
+  # `config.status --recheck' to rerun these tests and create the
+  # libtool script then.
+  test -f Makefile && make "$ltmain"
+fi
+
+if test -f "$ltmain"; then
+  trap "$rm \"${ofile}T\"; exit 1" 1 2 15
+  $rm -f "${ofile}T"
+
+  echo creating $ofile
+
+  # Now quote all the things that may contain metacharacters while being
+  # careful not to overquote the AC_SUBSTed values.  We take copies of the
+  # variables and quote the copies for generation of the libtool script.
+  for var in echo old_CC old_CFLAGS SED \
+    AR AR_FLAGS CC LD LN_S NM SHELL \
+    reload_flag reload_cmds wl \
+    pic_flag link_static_flag no_builtin_flag export_dynamic_flag_spec \
+    thread_safe_flag_spec whole_archive_flag_spec libname_spec \
+    library_names_spec soname_spec \
+    RANLIB old_archive_cmds old_archive_from_new_cmds old_postinstall_cmds \
+    old_postuninstall_cmds archive_cmds archive_expsym_cmds postinstall_cmds \
+    postuninstall_cmds extract_expsyms_cmds old_archive_from_expsyms_cmds \
+    old_striplib striplib file_magic_cmd export_symbols_cmds \
+    deplibs_check_method allow_undefined_flag no_undefined_flag \
+    finish_cmds finish_eval global_symbol_pipe global_symbol_to_cdecl \
+    global_symbol_to_c_name_address \
+    hardcode_libdir_flag_spec hardcode_libdir_separator  \
+    sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
+    compiler_c_o compiler_o_lo need_locks exclude_expsyms include_expsyms; do
+
+    case $var in
+    reload_cmds | old_archive_cmds | old_archive_from_new_cmds | \
+    old_postinstall_cmds | old_postuninstall_cmds | \
+    export_symbols_cmds | archive_cmds | archive_expsym_cmds | \
+    extract_expsyms_cmds | old_archive_from_expsyms_cmds | \
+    postinstall_cmds | postuninstall_cmds | \
+    finish_cmds | sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
+      # Double-quote double-evaled strings.
+      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
+      ;;
+    *)
+      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
+      ;;
+    esac
+  done
+
+  cat <<__EOF__ > "${ofile}T"
+#! $SHELL
+
+# `$echo "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
+# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP)
+# NOTE: Changes made to this file will be lost: look at ltmain.sh.
+#
+# Copyright (C) 1996-2000 Free Software Foundation, Inc.
+# Originally by Gordon Matzigkeit <gord at gnu.ai.mit.edu>, 1996
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# A sed that does not truncate output.
+SED=$lt_SED
+
+# Sed that helps us avoid accidentally triggering echo(1) options like -n.
+Xsed="${SED} -e s/^X//"
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+if test "X\${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi
+
+# ### BEGIN LIBTOOL CONFIG
+
+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+
+# Shell to use when invoking shell scripts.
+SHELL=$lt_SHELL
+
+# Whether or not to build shared libraries.
+build_libtool_libs=$enable_shared
+
+# Whether or not to build static libraries.
+build_old_libs=$enable_static
+
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$need_lc
+
+# Whether or not to optimize for fast installation.
+fast_install=$enable_fast_install
+
+# The host system.
+host_alias=$host_alias
+host=$host
+
+# An echo program that does not interpret backslashes.
+echo=$lt_echo
+
+# The archiver.
+AR=$lt_AR
+AR_FLAGS=$lt_AR_FLAGS
+
+# The default C compiler.
+CC=$lt_CC
+
+# Is the compiler the GNU C compiler?
+with_gcc=$GCC
+
+# The linker used to build libraries.
+LD=$lt_LD
+
+# Whether we need hard or soft links.
+LN_S=$lt_LN_S
+
+# A BSD-compatible nm program.
+NM=$lt_NM
+
+# A symbol stripping program
+STRIP=$STRIP
+
+# Used to examine libraries when file_magic_cmd begins "file"
+MAGIC_CMD=$MAGIC_CMD
+
+# Used on cygwin: DLL creation program.
+DLLTOOL="$DLLTOOL"
+
+# Used on cygwin: object dumper.
+OBJDUMP="$OBJDUMP"
+
+# Used on cygwin: assembler.
+AS=$lt_AS
+
+# The name of the directory that contains temporary libtool files.
+objdir=$objdir
+
+# How to create reloadable object files.
+reload_flag=$lt_reload_flag
+reload_cmds=$lt_reload_cmds
+
+# How to pass a linker flag through the compiler.
+wl=$lt_wl
+
+# Object file suffix (normally "o").
+objext="$ac_objext"
+
+# Old archive suffix (normally "a").
+libext="$libext"
+
+# Executable file suffix (normally "").
+exeext="$exeext"
+
+# Additional compiler flags for building library objects.
+pic_flag=$lt_pic_flag
+pic_mode=$pic_mode
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_compiler_c_o
+
+# Can we write directly to a .lo ?
+compiler_o_lo=$lt_compiler_o_lo
+
+# Must we lock files when doing compilation ?
+need_locks=$lt_need_locks
+
+# Do we need the lib prefix for modules?
+need_lib_prefix=$need_lib_prefix
+
+# Do we need a version for libraries?
+need_version=$need_version
+
+# Whether dlopen is supported.
+dlopen_support=$enable_dlopen
+
+# Whether dlopen of programs is supported.
+dlopen_self=$enable_dlopen_self
+
+# Whether dlopen of statically linked programs is supported.
+dlopen_self_static=$enable_dlopen_self_static
+
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$lt_link_static_flag
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_no_builtin_flag
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_whole_archive_flag_spec
+
+# Compiler flag to generate thread-safe objects.
+thread_safe_flag_spec=$lt_thread_safe_flag_spec
+
+# Library versioning type.
+version_type=$version_type
+
+# Format of library name prefix.
+libname_spec=$lt_libname_spec
+
+# List of archive names.  First name is the real one, the rest are links.
+# The last name is the one that the linker finds with -lNAME.
+library_names_spec=$lt_library_names_spec
+
+# The coded name of the library, if different from the real name.
+soname_spec=$lt_soname_spec
+
+# Commands used to build and install an old-style archive.
+RANLIB=$lt_RANLIB
+old_archive_cmds=$lt_old_archive_cmds
+old_postinstall_cmds=$lt_old_postinstall_cmds
+old_postuninstall_cmds=$lt_old_postuninstall_cmds
+
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds
+
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds
+
+# Commands used to build and install a shared archive.
+archive_cmds=$lt_archive_cmds
+archive_expsym_cmds=$lt_archive_expsym_cmds
+postinstall_cmds=$lt_postinstall_cmds
+postuninstall_cmds=$lt_postuninstall_cmds
+
+# Commands to strip libraries.
+old_striplib=$lt_old_striplib
+striplib=$lt_striplib
+
+# Method to check whether dependent libraries are shared objects.
+deplibs_check_method=$lt_deplibs_check_method
+
+# Command to use when deplibs_check_method == file_magic.
+file_magic_cmd=$lt_file_magic_cmd
+
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$lt_allow_undefined_flag
+
+# Flag that forces no undefined symbols.
+no_undefined_flag=$lt_no_undefined_flag
+
+# Commands used to finish a libtool library installation in a directory.
+finish_cmds=$lt_finish_cmds
+
+# Same as above, but a single script fragment to be evaled but not shown.
+finish_eval=$lt_finish_eval
+
+# Take the output of nm and produce a listing of raw symbols and C names.
+global_symbol_pipe=$lt_global_symbol_pipe
+
+# Transform the output of nm in a proper C declaration
+global_symbol_to_cdecl=$lt_global_symbol_to_cdecl
+
+# Transform the output of nm in a C name address pair
+global_symbol_to_c_name_address=$lt_global_symbol_to_c_name_address
+
+# This is the shared library runtime path variable.
+runpath_var=$runpath_var
+
+# This is the shared library path variable.
+shlibpath_var=$shlibpath_var
+
+# Is shlibpath searched before the hard-coded library search path?
+shlibpath_overrides_runpath=$shlibpath_overrides_runpath
+
+# How to hardcode a shared library path into an executable.
+hardcode_action=$hardcode_action
+
+# Whether we should hardcode library paths into libraries.
+hardcode_into_libs=$hardcode_into_libs
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist.
+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec
+
+# Whether we need a single -rpath flag with a separated argument.
+hardcode_libdir_separator=$lt_hardcode_libdir_separator
+
+# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the
+# resulting binary.
+hardcode_direct=$hardcode_direct
+
+# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
+# resulting binary.
+hardcode_minus_L=$hardcode_minus_L
+
+# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
+# the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var
+
+# Variables whose values should be saved in libtool wrapper scripts and
+# restored at relink time.
+variables_saved_for_relink="$variables_saved_for_relink"
+
+# Whether libtool must link a program against all its dependency libraries.
+link_all_deplibs=$link_all_deplibs
+
+# Compile-time system search path for libraries
+sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
+
+# Run-time system search path for libraries
+sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
+
+# Fix the shell variable \$srcfile for the compiler.
+fix_srcfile_path="$fix_srcfile_path"
+
+# Set to yes if exported symbols are required.
+always_export_symbols=$always_export_symbols
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_export_symbols_cmds
+
+# The commands to extract the exported symbol list from a shared archive.
+extract_expsyms_cmds=$lt_extract_expsyms_cmds
+
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$lt_exclude_expsyms
+
+# Symbols that must always be exported.
+include_expsyms=$lt_include_expsyms
+
+# ### END LIBTOOL CONFIG
+
+__EOF__
+
+  case $host_os in
+  aix3*)
+    cat <<\EOF >> "${ofile}T"
+
+# AIX sometimes has problems with the GCC collect2 program.  For some
+# reason, if we set the COLLECT_NAMES environment variable, the problems
+# vanish in a puff of smoke.
+if test "X${COLLECT_NAMES+set}" != Xset; then
+  COLLECT_NAMES=
+  export COLLECT_NAMES
+fi
+EOF
+    ;;
+  esac
+
+  case $host_os in
+  cygwin* | mingw* | pw32* | os2*)
+    cat <<'EOF' >> "${ofile}T"
+      # This is a source program that is used to create dlls on Windows
+      # Don't remove nor modify the starting and closing comments
+# /* ltdll.c starts here */
+# #define WIN32_LEAN_AND_MEAN
+# #include <windows.h>
+# #undef WIN32_LEAN_AND_MEAN
+# #include <stdio.h>
+#
+# #ifndef __CYGWIN__
+# #  ifdef __CYGWIN32__
+# #    define __CYGWIN__ __CYGWIN32__
+# #  endif
+# #endif
+#
+# #ifdef __cplusplus
+# extern "C" {
+# #endif
+# BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved);
+# #ifdef __cplusplus
+# }
+# #endif
+#
+# #ifdef __CYGWIN__
+# #include <cygwin/cygwin_dll.h>
+# DECLARE_CYGWIN_DLL( DllMain );
+# #endif
+# HINSTANCE __hDllInstance_base;
+#
+# BOOL APIENTRY
+# DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved)
+# {
+#   __hDllInstance_base = hInst;
+#   return TRUE;
+# }
+# /* ltdll.c ends here */
+	# This is a source program that is used to create import libraries
+	# on Windows for dlls which lack them. Don't remove nor modify the
+	# starting and closing comments
+# /* impgen.c starts here */
+# /*   Copyright (C) 1999-2000 Free Software Foundation, Inc.
+#
+#  This file is part of GNU libtool.
+#
+#  This program is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software
+#  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#  */
+#
+# #include <stdio.h>		/* for printf() */
+# #include <unistd.h>		/* for open(), lseek(), read() */
+# #include <fcntl.h>		/* for O_RDONLY, O_BINARY */
+# #include <string.h>		/* for strdup() */
+#
+# /* O_BINARY isn't required (or even defined sometimes) under Unix */
+# #ifndef O_BINARY
+# #define O_BINARY 0
+# #endif
+#
+# static unsigned int
+# pe_get16 (fd, offset)
+#      int fd;
+#      int offset;
+# {
+#   unsigned char b[2];
+#   lseek (fd, offset, SEEK_SET);
+#   read (fd, b, 2);
+#   return b[0] + (b[1]<<8);
+# }
+#
+# static unsigned int
+# pe_get32 (fd, offset)
+#     int fd;
+#     int offset;
+# {
+#   unsigned char b[4];
+#   lseek (fd, offset, SEEK_SET);
+#   read (fd, b, 4);
+#   return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24);
+# }
+#
+# static unsigned int
+# pe_as32 (ptr)
+#      void *ptr;
+# {
+#   unsigned char *b = ptr;
+#   return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24);
+# }
+#
+# int
+# main (argc, argv)
+#     int argc;
+#     char *argv[];
+# {
+#     int dll;
+#     unsigned long pe_header_offset, opthdr_ofs, num_entries, i;
+#     unsigned long export_rva, export_size, nsections, secptr, expptr;
+#     unsigned long name_rvas, nexp;
+#     unsigned char *expdata, *erva;
+#     char *filename, *dll_name;
+#
+#     filename = argv[1];
+#
+#     dll = open(filename, O_RDONLY|O_BINARY);
+#     if (dll < 1)
+# 	return 1;
+#
+#     dll_name = filename;
+#
+#     for (i=0; filename[i]; i++)
+# 	if (filename[i] == '/' || filename[i] == '\\'  || filename[i] == ':')
+# 	    dll_name = filename + i +1;
+#
+#     pe_header_offset = pe_get32 (dll, 0x3c);
+#     opthdr_ofs = pe_header_offset + 4 + 20;
+#     num_entries = pe_get32 (dll, opthdr_ofs + 92);
+#
+#     if (num_entries < 1) /* no exports */
+# 	return 1;
+#
+#     export_rva = pe_get32 (dll, opthdr_ofs + 96);
+#     export_size = pe_get32 (dll, opthdr_ofs + 100);
+#     nsections = pe_get16 (dll, pe_header_offset + 4 +2);
+#     secptr = (pe_header_offset + 4 + 20 +
+# 	      pe_get16 (dll, pe_header_offset + 4 + 16));
+#
+#     expptr = 0;
+#     for (i = 0; i < nsections; i++)
+#     {
+# 	char sname[8];
+# 	unsigned long secptr1 = secptr + 40 * i;
+# 	unsigned long vaddr = pe_get32 (dll, secptr1 + 12);
+# 	unsigned long vsize = pe_get32 (dll, secptr1 + 16);
+# 	unsigned long fptr = pe_get32 (dll, secptr1 + 20);
+# 	lseek(dll, secptr1, SEEK_SET);
+# 	read(dll, sname, 8);
+# 	if (vaddr <= export_rva && vaddr+vsize > export_rva)
+# 	{
+# 	    expptr = fptr + (export_rva - vaddr);
+# 	    if (export_rva + export_size > vaddr + vsize)
+# 		export_size = vsize - (export_rva - vaddr);
+# 	    break;
+# 	}
+#     }
+#
+#     expdata = (unsigned char*)malloc(export_size);
+#     lseek (dll, expptr, SEEK_SET);
+#     read (dll, expdata, export_size);
+#     erva = expdata - export_rva;
+#
+#     nexp = pe_as32 (expdata+24);
+#     name_rvas = pe_as32 (expdata+32);
+#
+#     printf ("EXPORTS\n");
+#     for (i = 0; i<nexp; i++)
+#     {
+# 	unsigned long name_rva = pe_as32 (erva+name_rvas+i*4);
+# 	printf ("\t%s @ %ld ;\n", erva+name_rva, 1+ i);
+#     }
+#
+#     return 0;
+# }
+# /* impgen.c ends here */
+
+EOF
+    ;;
+  esac
+
+  # We use sed instead of cat because bash on DJGPP gets confused if
+  # if finds mixed CR/LF and LF-only lines.  Since sed operates in
+  # text mode, it properly converts lines to CR/LF.  This bash problem
+  # is reportedly fixed, but why not run on old versions too?
+  sed '$q' "$ltmain" >> "${ofile}T" || (rm -f "${ofile}T"; exit 1)
+
+  mv -f "${ofile}T" "$ofile" || \
+    (rm -f "$ofile" && cp "${ofile}T" "$ofile" && rm -f "${ofile}T")
+  chmod +x "$ofile"
+fi
+
+])# _LT_AC_LTCONFIG_HACK
+
+# AC_LIBTOOL_DLOPEN - enable checks for dlopen support
+AC_DEFUN([AC_LIBTOOL_DLOPEN], [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])])
+
+# AC_LIBTOOL_WIN32_DLL - declare package support for building win32 dll's
+AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])])
+
+# AC_ENABLE_SHARED - implement the --enable-shared flag
+# Usage: AC_ENABLE_SHARED[(DEFAULT)]
+#   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
+#   `yes'.
+AC_DEFUN([AC_ENABLE_SHARED],
+[define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
+AC_ARG_ENABLE(shared,
+changequote(<<, >>)dnl
+<<  --enable-shared[=PKGS]  build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT],
+changequote([, ])dnl
+[p=${PACKAGE-default}
+case $enableval in
+yes) enable_shared=yes ;;
+no) enable_shared=no ;;
+*)
+  enable_shared=no
+  # Look at the argument we got.  We use all the common list separators.
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
+  for pkg in $enableval; do
+    if test "X$pkg" = "X$p"; then
+      enable_shared=yes
+    fi
+  done
+  IFS="$ac_save_ifs"
+  ;;
+esac],
+enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl
+])
+
+# AC_DISABLE_SHARED - set the default shared flag to --disable-shared
+AC_DEFUN([AC_DISABLE_SHARED],
+[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+AC_ENABLE_SHARED(no)])
+
+# AC_ENABLE_STATIC - implement the --enable-static flag
+# Usage: AC_ENABLE_STATIC[(DEFAULT)]
+#   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
+#   `yes'.
+AC_DEFUN([AC_ENABLE_STATIC],
+[define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
+AC_ARG_ENABLE(static,
+changequote(<<, >>)dnl
+<<  --enable-static[=PKGS]  build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT],
+changequote([, ])dnl
+[p=${PACKAGE-default}
+case $enableval in
+yes) enable_static=yes ;;
+no) enable_static=no ;;
+*)
+  enable_static=no
+  # Look at the argument we got.  We use all the common list separators.
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
+  for pkg in $enableval; do
+    if test "X$pkg" = "X$p"; then
+      enable_static=yes
+    fi
+  done
+  IFS="$ac_save_ifs"
+  ;;
+esac],
+enable_static=AC_ENABLE_STATIC_DEFAULT)dnl
+])
+
+# AC_DISABLE_STATIC - set the default static flag to --disable-static
+AC_DEFUN([AC_DISABLE_STATIC],
+[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+AC_ENABLE_STATIC(no)])
+
+
+# AC_ENABLE_FAST_INSTALL - implement the --enable-fast-install flag
+# Usage: AC_ENABLE_FAST_INSTALL[(DEFAULT)]
+#   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
+#   `yes'.
+AC_DEFUN([AC_ENABLE_FAST_INSTALL],
+[define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl
+AC_ARG_ENABLE(fast-install,
+changequote(<<, >>)dnl
+<<  --enable-fast-install[=PKGS]  optimize for fast installation [default=>>AC_ENABLE_FAST_INSTALL_DEFAULT],
+changequote([, ])dnl
+[p=${PACKAGE-default}
+case $enableval in
+yes) enable_fast_install=yes ;;
+no) enable_fast_install=no ;;
+*)
+  enable_fast_install=no
+  # Look at the argument we got.  We use all the common list separators.
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
+  for pkg in $enableval; do
+    if test "X$pkg" = "X$p"; then
+      enable_fast_install=yes
+    fi
+  done
+  IFS="$ac_save_ifs"
+  ;;
+esac],
+enable_fast_install=AC_ENABLE_FAST_INSTALL_DEFAULT)dnl
+])
+
+# AC_DISABLE_FAST_INSTALL - set the default to --disable-fast-install
+AC_DEFUN([AC_DISABLE_FAST_INSTALL],
+[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+AC_ENABLE_FAST_INSTALL(no)])
+
+# AC_LIBTOOL_PICMODE - implement the --with-pic flag
+# Usage: AC_LIBTOOL_PICMODE[(MODE)]
+#   Where MODE is either `yes' or `no'.  If omitted, it defaults to
+#   `both'.
+AC_DEFUN([AC_LIBTOOL_PICMODE],
+[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+pic_mode=ifelse($#,1,$1,default)])
+
+
+# AC_PATH_TOOL_PREFIX - find a file program which can recognise shared library
+AC_DEFUN([AC_PATH_TOOL_PREFIX],
+[AC_MSG_CHECKING([for $1])
+AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
+[case $MAGIC_CMD in
+  /*)
+  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  ;;
+  ?:/*)
+  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a dos path.
+  ;;
+  *)
+  ac_save_MAGIC_CMD="$MAGIC_CMD"
+  IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
+dnl $ac_dummy forces splitting on constant user-supplied paths.
+dnl POSIX.2 word splitting is done only on the output of word expansions,
+dnl not every word.  This closes a longstanding sh security hole.
+  ac_dummy="ifelse([$2], , $PATH, [$2])"
+  for ac_dir in $ac_dummy; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$1; then
+      lt_cv_path_MAGIC_CMD="$ac_dir/$1"
+      if test -n "$file_magic_test_file"; then
+	case $deplibs_check_method in
+	"file_magic "*)
+	  file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`"
+	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+	    egrep "$file_magic_regex" > /dev/null; then
+	    :
+	  else
+	    cat <<EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such.  This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem.  Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool at gnu.org
+
+EOF
+	  fi ;;
+	esac
+      fi
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+  MAGIC_CMD="$ac_save_MAGIC_CMD"
+  ;;
+esac])
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+  AC_MSG_RESULT($MAGIC_CMD)
+else
+  AC_MSG_RESULT(no)
+fi
+])
+
+
+# AC_PATH_MAGIC - find a file program which can recognise a shared library
+AC_DEFUN([AC_PATH_MAGIC],
+[AC_REQUIRE([AC_CHECK_TOOL_PREFIX])dnl
+AC_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin:$PATH)
+if test -z "$lt_cv_path_MAGIC_CMD"; then
+  if test -n "$ac_tool_prefix"; then
+    AC_PATH_TOOL_PREFIX(file, /usr/bin:$PATH)
+  else
+    MAGIC_CMD=:
+  fi
+fi
+])
+
+
+# AC_PROG_LD - find the path to the GNU or non-GNU linker
+AC_DEFUN([AC_PROG_LD],
+[AC_ARG_WITH(gnu-ld,
+[  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]],
+test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+AC_REQUIRE([_LT_AC_LIBTOOL_SYS_PATH_SEPARATOR])dnl
+ac_prog=ld
+if test "$GCC" = yes; then
+  # Check if gcc -print-prog-name=ld gives a path.
+  AC_MSG_CHECKING([for ld used by GCC])
+  case $host in
+  *-*-mingw*)
+    # gcc leaves a trailing carriage return which upsets mingw
+    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+  *)
+    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+  esac
+  case $ac_prog in
+    # Accept absolute paths.
+    [[\\/]]* | [[A-Za-z]]:[[\\/]]*)
+      re_direlt='/[[^/]][[^/]]*/\.\./'
+      # Canonicalize the path of ld
+      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
+      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
+	ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
+      done
+      test -z "$LD" && LD="$ac_prog"
+      ;;
+  "")
+    # If it fails, then pretend we aren't using GCC.
+    ac_prog=ld
+    ;;
+  *)
+    # If it is relative, then search for the first ld in PATH.
+    with_gnu_ld=unknown
+    ;;
+  esac
+elif test "$with_gnu_ld" = yes; then
+  AC_MSG_CHECKING([for GNU ld])
+else
+  AC_MSG_CHECKING([for non-GNU ld])
+fi
+AC_CACHE_VAL(lt_cv_path_LD,
+[if test -z "$LD"; then
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  for ac_dir in $PATH; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+      lt_cv_path_LD="$ac_dir/$ac_prog"
+      # Check to see if the program is GNU ld.  I'd rather use --version,
+      # but apparently some GNU ld's only accept -v.
+      # Break only if it was the GNU/non-GNU ld that we prefer.
+      if "$lt_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
+	test "$with_gnu_ld" != no && break
+      else
+	test "$with_gnu_ld" != yes && break
+      fi
+    fi
+  done
+  IFS="$ac_save_ifs"
+else
+  lt_cv_path_LD="$LD" # Let the user override the test with a path.
+fi])
+LD="$lt_cv_path_LD"
+if test -n "$LD"; then
+  AC_MSG_RESULT($LD)
+else
+  AC_MSG_RESULT(no)
+fi
+test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
+AC_PROG_LD_GNU
+])
+
+# AC_PROG_LD_GNU -
+AC_DEFUN([AC_PROG_LD_GNU],
+[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
+[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
+if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
+  lt_cv_prog_gnu_ld=yes
+else
+  lt_cv_prog_gnu_ld=no
+fi])
+with_gnu_ld=$lt_cv_prog_gnu_ld
+])
+
+# AC_PROG_LD_RELOAD_FLAG - find reload flag for linker
+#   -- PORTME Some linkers may need a different reload flag.
+AC_DEFUN([AC_PROG_LD_RELOAD_FLAG],
+[AC_CACHE_CHECK([for $LD option to reload object files], lt_cv_ld_reload_flag,
+[lt_cv_ld_reload_flag='-r'])
+reload_flag=$lt_cv_ld_reload_flag
+test -n "$reload_flag" && reload_flag=" $reload_flag"
+])
+
+# AC_DEPLIBS_CHECK_METHOD - how to check for library dependencies
+#  -- PORTME fill in with the dynamic library characteristics
+AC_DEFUN([AC_DEPLIBS_CHECK_METHOD],
+[AC_CACHE_CHECK([how to recognise dependent libraries],
+lt_cv_deplibs_check_method,
+[lt_cv_file_magic_cmd='$MAGIC_CMD'
+lt_cv_file_magic_test_file=
+lt_cv_deplibs_check_method='unknown'
+# Need to set the preceding variable on all platforms that support
+# interlibrary dependencies.
+# 'none' -- dependencies not supported.
+# `unknown' -- same as none, but documents that we really don't know.
+# 'pass_all' -- all dependencies passed with no checks.
+# 'test_compile' -- check by making test program.
+# 'file_magic [[regex]]' -- check by looking for files in library path
+# which responds to the $file_magic_cmd with a given egrep regex.
+# If you have `file' or equivalent on your system and you're not sure
+# whether `pass_all' will *always* work, you probably want this one.
+
+case $host_os in
+aix4* | aix5*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+beos*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+bsdi4*)
+  lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)'
+  lt_cv_file_magic_cmd='/usr/bin/file -L'
+  lt_cv_file_magic_test_file=/shlib/libc.so
+  ;;
+
+cygwin* | mingw* | pw32*)
+  lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
+  lt_cv_file_magic_cmd='$OBJDUMP -f'
+  ;;
+
+darwin* | rhapsody*)
+  lt_cv_deplibs_check_method='file_magic Mach-O dynamically linked shared library'
+  lt_cv_file_magic_cmd='/usr/bin/file -L'
+  case "$host_os" in
+  rhapsody* | darwin1.[[012]])
+    lt_cv_file_magic_test_file=`echo /System/Library/Frameworks/System.framework/Versions/*/System | head -1`
+    ;;
+  *) # Darwin 1.3 on
+    lt_cv_file_magic_test_file='/usr/lib/libSystem.dylib'
+    ;;
+  esac
+  ;;
+
+freebsd*)
+  if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+    case $host_cpu in
+    i*86 )
+      # Not sure whether the presence of OpenBSD here was a mistake.
+      # Let's accept both of them until this is cleared up.
+      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD)/i[[3-9]]86 (compact )?demand paged shared library'
+      lt_cv_file_magic_cmd=/usr/bin/file
+      lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
+      ;;
+    esac
+  else
+    lt_cv_deplibs_check_method=pass_all
+  fi
+  ;;
+
+gnu*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+hpux10.20*|hpux11*)
+  lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library'
+  lt_cv_file_magic_cmd=/usr/bin/file
+  lt_cv_file_magic_test_file=/usr/lib/libc.sl
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $host_os in
+  irix5* | nonstopux*)
+    # this will be overridden with pass_all, but let us keep it just in case
+    lt_cv_deplibs_check_method="file_magic ELF 32-bit MSB dynamic lib MIPS - version 1"
+    ;;
+  *)
+    case $LD in
+    *-32|*"-32 ") libmagic=32-bit;;
+    *-n32|*"-n32 ") libmagic=N32;;
+    *-64|*"-64 ") libmagic=64-bit;;
+    *) libmagic=never-match;;
+    esac
+    # this will be overridden with pass_all, but let us keep it just in case
+    lt_cv_deplibs_check_method="file_magic ELF ${libmagic} MSB mips-[[1234]] dynamic lib MIPS - version 1"
+    ;;
+  esac
+  lt_cv_file_magic_test_file=`echo /lib${libsuff}/libc.so*`
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+# This must be Linux ELF.
+linux*)
+  case $host_cpu in
+  alpha* | hppa* | i*86 | m68* | mips | mipsel | powerpc* | s390* | sparc* | ia64* | x86_64*)
+    lt_cv_deplibs_check_method=pass_all ;;
+  *)
+    # glibc up to 2.1.1 does not perform some relocations on ARM
+    lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' ;;
+  esac
+  lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+  ;;
+
+netbsd*)
+  if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+    lt_cv_deplibs_check_method='match_pattern /lib[[^/\.]]+\.so\.[[0-9]]+\.[[0-9]]+$'
+  else
+    lt_cv_deplibs_check_method='match_pattern /lib[[^/\.]]+\.so$'
+  fi
+  ;;
+
+newos6*)
+  lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)'
+  lt_cv_file_magic_cmd=/usr/bin/file
+  lt_cv_file_magic_test_file=/usr/lib/libnls.so
+  ;;
+
+openbsd*)
+  lt_cv_file_magic_cmd=/usr/bin/file
+  lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
+  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB shared object'
+  else
+    lt_cv_deplibs_check_method='file_magic OpenBSD.* shared library'
+  fi
+  ;;
+
+osf3* | osf4* | osf5*)
+  # this will be overridden with pass_all, but let us keep it just in case
+  lt_cv_deplibs_check_method='file_magic COFF format alpha shared library'
+  lt_cv_file_magic_test_file=/shlib/libc.so
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+sco3.2v5*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+solaris*)
+  lt_cv_deplibs_check_method=pass_all
+  lt_cv_file_magic_test_file=/lib/libc.so
+  ;;
+
+sysv5uw[[78]]* | sysv4*uw2*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+  case $host_vendor in
+  motorola)
+    lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]'
+    lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
+    ;;
+  ncr)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  sequent)
+    lt_cv_file_magic_cmd='/bin/file'
+    lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )'
+    ;;
+  sni)
+    lt_cv_file_magic_cmd='/bin/file'
+    lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib"
+    lt_cv_file_magic_test_file=/lib/libc.so
+    ;;
+  siemens)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  esac
+  ;;
+esac
+])
+file_magic_cmd=$lt_cv_file_magic_cmd
+deplibs_check_method=$lt_cv_deplibs_check_method
+])
+
+
+# AC_PROG_NM - find the path to a BSD-compatible name lister
+AC_DEFUN([AC_PROG_NM],
+[AC_REQUIRE([_LT_AC_LIBTOOL_SYS_PATH_SEPARATOR])dnl
+AC_MSG_CHECKING([for BSD-compatible nm])
+AC_CACHE_VAL(lt_cv_path_NM,
+[if test -n "$NM"; then
+  # Let the user override the test.
+  lt_cv_path_NM="$NM"
+else
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do
+    test -z "$ac_dir" && ac_dir=.
+    tmp_nm=$ac_dir/${ac_tool_prefix}nm
+    if test -f $tmp_nm || test -f $tmp_nm$ac_exeext ; then
+      # Check to see if the nm accepts a BSD-compat flag.
+      # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+      #   nm: unknown option "B" ignored
+      # Tru64's nm complains that /dev/null is an invalid object file
+      if ($tmp_nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep '(/dev/null|Invalid file or object type)' >/dev/null; then
+	lt_cv_path_NM="$tmp_nm -B"
+	break
+      elif ($tmp_nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
+	lt_cv_path_NM="$tmp_nm -p"
+	break
+      else
+	lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+	continue # so that we can try to find one that supports BSD flags
+      fi
+    fi
+  done
+  IFS="$ac_save_ifs"
+  test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm
+fi])
+NM="$lt_cv_path_NM"
+AC_MSG_RESULT([$NM])
+])
+
+# AC_CHECK_LIBM - check for math library
+AC_DEFUN([AC_CHECK_LIBM],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+LIBM=
+case $host in
+*-*-beos* | *-*-cygwin* | *-*-pw32*)
+  # These system don't have libm
+  ;;
+*-ncr-sysv4.3*)
+  AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
+  AC_CHECK_LIB(m, main, LIBM="$LIBM -lm")
+  ;;
+*)
+  AC_CHECK_LIB(m, main, LIBM="-lm")
+  ;;
+esac
+])
+
+# AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for
+# the libltdl convenience library and LTDLINCL to the include flags for
+# the libltdl header and adds --enable-ltdl-convenience to the
+# configure arguments.  Note that LIBLTDL and LTDLINCL are not
+# AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called.  If DIR is not
+# provided, it is assumed to be `libltdl'.  LIBLTDL will be prefixed
+# with '${top_builddir}/' and LTDLINCL will be prefixed with
+# '${top_srcdir}/' (note the single quotes!).  If your package is not
+# flat and you're not using automake, define top_builddir and
+# top_srcdir appropriately in the Makefiles.
+AC_DEFUN([AC_LIBLTDL_CONVENIENCE],
+[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+  case $enable_ltdl_convenience in
+  no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;;
+  "") enable_ltdl_convenience=yes
+      ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;;
+  esac
+  LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la
+  LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
+  # For backwards non-gettext consistent compatibility...
+  INCLTDL="$LTDLINCL"
+])
+
+# AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for
+# the libltdl installable library and LTDLINCL to the include flags for
+# the libltdl header and adds --enable-ltdl-install to the configure
+# arguments.  Note that LIBLTDL and LTDLINCL are not AC_SUBSTed, nor is
+# AC_CONFIG_SUBDIRS called.  If DIR is not provided and an installed
+# libltdl is not found, it is assumed to be `libltdl'.  LIBLTDL will
+# be prefixed with '${top_builddir}/' and LTDLINCL will be prefixed
+# with '${top_srcdir}/' (note the single quotes!).  If your package is
+# not flat and you're not using automake, define top_builddir and
+# top_srcdir appropriately in the Makefiles.
+# In the future, this macro may have to be called after AC_PROG_LIBTOOL.
+AC_DEFUN([AC_LIBLTDL_INSTALLABLE],
+[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+  AC_CHECK_LIB(ltdl, main,
+  [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no],
+  [if test x"$enable_ltdl_install" = xno; then
+     AC_MSG_WARN([libltdl not installed, but installation disabled])
+   else
+     enable_ltdl_install=yes
+   fi
+  ])
+  if test x"$enable_ltdl_install" = x"yes"; then
+    ac_configure_args="$ac_configure_args --enable-ltdl-install"
+    LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la
+    LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
+  else
+    ac_configure_args="$ac_configure_args --enable-ltdl-install=no"
+    LIBLTDL="-lltdl"
+    LTDLINCL=
+  fi
+  # For backwards non-gettext consistent compatibility...
+  INCLTDL="$LTDLINCL"
+])
+
+# old names
+AC_DEFUN([AM_PROG_LIBTOOL],   [AC_PROG_LIBTOOL])
+AC_DEFUN([AM_ENABLE_SHARED],  [AC_ENABLE_SHARED($@)])
+AC_DEFUN([AM_ENABLE_STATIC],  [AC_ENABLE_STATIC($@)])
+AC_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
+AC_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
+AC_DEFUN([AM_PROG_LD],        [AC_PROG_LD])
+AC_DEFUN([AM_PROG_NM],        [AC_PROG_NM])
+
+# This is just to silence aclocal about the macro not being used
+ifelse([AC_DISABLE_FAST_INSTALL])
+
+# NOTE: This macro has been submitted for inclusion into   #
+#  GNU Autoconf as AC_PROG_SED.  When it is available in   #
+#  a released version of Autoconf we should remove this    #
+#  macro and use it instead.                               #
+# LT_AC_PROG_SED
+# --------------
+# Check for a fully-functional sed program, that truncates
+# as few characters as possible.  Prefer GNU sed if found.
+AC_DEFUN([LT_AC_PROG_SED],
+[AC_MSG_CHECKING([for a sed that does not truncate output])
+AC_CACHE_VAL(lt_cv_path_SED,
+[# Loop through the user's path and test for sed and gsed.
+# Then use that list of sed's as ones to test for truncation.
+as_executable_p="test -f"
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_prog in sed gsed; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
+        _sed_list="$_sed_list $as_dir/$ac_prog$ac_exec_ext"
+      fi
+    done
+  done
+done
+
+  # Create a temporary directory, and hook for its removal unless debugging.
+$debug ||
+{
+  trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0
+  trap '{ (exit 1); exit 1; }' 1 2 13 15
+}
+
+# Create a (secure) tmp directory for tmp files.
+: ${TMPDIR=/tmp}
+{
+  tmp=`(umask 077 && mktemp -d -q "$TMPDIR/sedXXXXXX") 2>/dev/null` &&
+  test -n "$tmp" && test -d "$tmp"
+}  ||
+{
+  tmp=$TMPDIR/sed$$-$RANDOM
+  (umask 077 && mkdir $tmp)
+} ||
+{
+   echo "$me: cannot create a temporary directory in $TMPDIR" >&2
+   { (exit 1); exit 1; }
+}
+  _max=0
+  _count=0
+  # Add /usr/xpg4/bin/sed as it is typically found on Solaris
+  # along with /bin/sed that truncates output.
+  for _sed in $_sed_list /usr/xpg4/bin/sed; do
+    test ! -f ${_sed} && break
+    cat /dev/null > "$tmp/sed.in"
+    _count=0
+    echo ${ECHO_N-$ac_n} "0123456789${ECHO_C-$ac_c}" >"$tmp/sed.in"
+    # Check for GNU sed and select it if it is found.
+    if "${_sed}" --version 2>&1 < /dev/null | egrep '(GNU)' > /dev/null; then
+      lt_cv_path_SED=${_sed}
+      break
+    fi
+    while true; do
+      cat "$tmp/sed.in" "$tmp/sed.in" >"$tmp/sed.tmp"
+      mv "$tmp/sed.tmp" "$tmp/sed.in"
+      cp "$tmp/sed.in" "$tmp/sed.nl"
+      echo >>"$tmp/sed.nl"
+      ${_sed} -e 's/a$//' < "$tmp/sed.nl" >"$tmp/sed.out" || break
+      cmp -s "$tmp/sed.out" "$tmp/sed.nl" || break
+      # 40000 chars as input seems more than enough
+      test $_count -gt 10 && break
+      _count=`expr $_count + 1`
+      if test $_count -gt $_max; then
+        _max=$_count
+        lt_cv_path_SED=$_sed
+      fi
+    done
+  done
+  rm -rf "$tmp"
+])
+if test "X$SED" != "X"; then
+  lt_cv_path_SED=$SED
+else
+  SED=$lt_cv_path_SED
+fi
+AC_MSG_RESULT([$SED])
+])
+

Added: experimental/j/Elphel333/rtp/daemon/rtp/addrinfo.h
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/addrinfo.h	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/addrinfo.h	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,122 @@
+/*
+ * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/* $Id: addrinfo.h,v 1.1.1.1 2005/03/18 09:18:47 elphel Exp $ */
+
+#ifndef HAVE_ADDRINFO
+
+/*
+ * Error return codes from getaddrinfo()
+ */
+#define	EAI_ADDRFAMILY	 1	/* address family for hostname not supported */
+#define	EAI_AGAIN	 2	/* temporary failure in name resolution */
+#define	EAI_BADFLAGS	 3	/* invalid value for ai_flags */
+#define	EAI_FAIL	 4	/* non-recoverable failure in name resolution */
+#define	EAI_FAMILY	 5	/* ai_family not supported */
+#define	EAI_MEMORY	 6	/* memory allocation failure */
+#define	EAI_NODATA	 7	/* no address associated with hostname */
+#define	EAI_NONAME	 8	/* hostname nor servname provided, or not known */
+#define	EAI_SERVICE	 9	/* servname not supported for ai_socktype */
+#define	EAI_SOCKTYPE	10	/* ai_socktype not supported */
+#define	EAI_SYSTEM	11	/* system error returned in errno */
+#define EAI_BADHINTS	12
+#define EAI_PROTOCOL	13
+#define EAI_MAX		14
+
+/* internal error */
+#define	NETDB_INTERNAL	-1	/* see errno */
+
+/*
+ * Flag values for getaddrinfo()
+ */
+#define	AI_PASSIVE	0x00000001 /* get address to use bind() */
+#define	AI_CANONNAME	0x00000002 /* fill ai_canonname */
+#define	AI_NUMERICHOST	0x00000004 /* prevent name resolution */
+/* valid flags for addrinfo */
+#define	AI_MASK		(AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST)
+
+#define	AI_ALL		0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */
+#define	AI_V4MAPPED_CFG	0x00000200 /* accept IPv4-mapped if kernel supports */
+#define	AI_ADDRCONFIG	0x00000400 /* only if any address is assigned */
+#define	AI_V4MAPPED	0x00000800 /* accept IPv4-mapped IPv6 address */
+/* special recommended flags for getipnodebyname */
+#define	AI_DEFAULT	(AI_V4MAPPED_CFG | AI_ADDRCONFIG)
+
+struct addrinfo {
+	int	ai_flags;	/* AI_PASSIVE, AI_CANONNAME */
+	int	ai_family;	/* PF_xxx */
+	int	ai_socktype;	/* SOCK_xxx */
+	int	ai_protocol;	/* 0 or IPPROTO_xxx for IPv4 and IPv6 */
+	size_t	ai_addrlen;	/* length of ai_addr */
+	char	*ai_canonname;	/* canonical name for hostname */
+	struct sockaddr *ai_addr;	/* binary address */
+	struct addrinfo *ai_next;	/* next structure in linked list */
+};
+
+extern void freeaddrinfo __P((struct addrinfo *));
+extern void freehostent __P((struct hostent *));
+extern char *gai_strerror __P((int));
+extern int getaddrinfo __P((const char *, const char *,
+			    const struct addrinfo *, struct addrinfo **));
+extern int getnameinfo __P((const struct sockaddr *, size_t, char *,
+			    size_t, char *, size_t, int));
+extern struct hostent *getipnodebyaddr __P((const void *, size_t, int, int *));
+extern struct hostent *getipnodebyname __P((const char *, int, int, int *));
+extern int inet_pton __P((int, const char *, void *));
+extern const char *inet_ntop __P((int, const void *, char *, size_t));
+#endif /* HAVE_ADDRINFO */
+
+/*
+ * Constants for getnameinfo()
+ */
+#ifndef NI_MAXHOST
+#define	NI_MAXHOST	1025
+#endif
+#ifndef NI_MAXSERV
+#define	NI_MAXSERV	32
+#endif
+
+/*
+ * Flag values for getnameinfo()
+ */
+#ifndef NI_NOFQDN
+#define	NI_NOFQDN	0x00000001
+#endif
+#ifndef NI_NUMERICHOST
+#define	NI_NUMERICHOST	0x00000002
+#endif
+#ifndef NI_NAMEREQD
+#define	NI_NAMEREQD	0x00000004
+#endif
+#ifndef NI_NUMERICSERV
+#define	NI_NUMERICSERV	0x00000008
+#endif
+#ifndef NI_DGRAM
+#define	NI_DGRAM	0x00000010
+#endif

Added: experimental/j/Elphel333/rtp/daemon/rtp/addrsize.h
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/addrsize.h	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/addrsize.h	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 1999 WIDE Project.
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#ifndef INADDRSZ 
+#define INADDRSZ 4		/* IPv4 T_A */
+#endif
+
+#ifndef IN6ADDRSZ
+#define IN6ADDRSZ	16	/* IPv6 T_AAAA */
+#endif 
+

Added: experimental/j/Elphel333/rtp/daemon/rtp/asarray.c
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/asarray.c	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/asarray.c	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,172 @@
+/*
+ * FILE:    asarray.c
+ *
+ * AUTHORS: Orion Hodson
+ *
+ * Copyright (c) 1999-2000 University College London
+ * All rights reserved.
+ */
+ 
+#include "config_unix.h"
+#include "config_win32.h"
+
+#include "debug.h"
+#include "memory.h"
+#include "util.h"
+
+#include "asarray.h"
+
+typedef struct s_hash_tuple {
+        uint32_t hash;
+        char *key;
+        char *value;
+        struct s_hash_tuple *next;
+} hash_tuple;
+
+#define ASARRAY_SIZE 11
+
+struct _asarray {
+        hash_tuple *table[ASARRAY_SIZE];
+        int32_t     nitems[ASARRAY_SIZE];
+};
+
+static uint32_t 
+asarray_hash(const char *key)
+{
+        uint32_t hash = 0;
+
+        while(*key != '\0') {
+                hash = hash * 31;
+                hash += ((uint32_t)*key) + 1;
+                key++;
+        }
+
+        return hash;
+}
+
+int32_t
+asarray_add(asarray *pa, const char *key, const char *value)
+{
+        hash_tuple *t;
+        int row;
+
+        t = (hash_tuple*)xmalloc(sizeof(hash_tuple));
+        if (t) {
+                /* transfer values */
+                t->hash  = asarray_hash(key);
+                t->key   = xstrdup(key);
+                t->value = xstrdup(value);
+                /* Add to table */
+                row            = t->hash % ASARRAY_SIZE;
+                t->next        = pa->table[row];
+                pa->table[row] = t;
+                pa->nitems[row]++;
+                return TRUE;
+        }
+        return FALSE;
+}
+
+void
+asarray_remove(asarray *pa, const char *key)
+{
+        hash_tuple **t, *e;
+        uint32_t hash;
+        int row;
+
+        hash = asarray_hash(key);
+        row  = hash % ASARRAY_SIZE;
+        t    = &pa->table[row];
+        while((*t) != NULL) {
+                if ((hash == (*t)->hash) && 
+                    (strcmp(key, (*t)->key) == 0)) {
+                        e = *t;
+                        *t = e->next;
+                        xfree(e->key);
+                        xfree(e->value);
+                        xfree(e);
+                        pa->nitems[row]--;
+                        ASSERT(pa->nitems[row] >= 0);
+                        break;
+                } else {
+                        t = &(*t)->next;
+                }
+        }
+}
+
+const char* 
+asarray_get_key_no(asarray *pa, int32_t index)
+{
+        int32_t row = 0;
+
+        index += 1;
+        while (row < ASARRAY_SIZE && index > pa->nitems[row]) {
+                index -= pa->nitems[row];
+                row++;
+        }
+
+        if (row < ASARRAY_SIZE) {
+                hash_tuple *t;
+                t = pa->table[row];
+                while(--index > 0) {
+                        ASSERT(t->next != NULL);
+                        t = t->next;
+                }
+                return t->key;
+        }
+        return NULL;
+}
+
+/* asarray_lookup points value at actual value        */
+/* and return TRUE if key found.                      */
+int32_t
+asarray_lookup(asarray *pa, const char *key, char **value)
+{
+        hash_tuple *t;
+        int          row;
+        uint32_t     hash;
+
+        hash = asarray_hash(key);
+        row  = hash % ASARRAY_SIZE;
+
+        t = pa->table[row];
+        while(t != NULL) {
+                if (t->hash == hash && strcmp(key, t->key) == 0) {
+                        *value = t->value;
+                        return TRUE;
+                }
+                t = t->next;
+        }
+        *value = NULL;
+        return FALSE;
+}
+
+int32_t
+asarray_create(asarray **ppa)
+{
+        asarray *pa;
+        pa = (asarray*)xmalloc(sizeof(asarray));
+        if (pa != NULL) {
+                memset(pa, 0, sizeof(asarray));
+                *ppa = pa;
+                return TRUE;
+        }
+        return FALSE;
+}
+
+void
+asarray_destroy(asarray **ppa)
+{
+        asarray    *pa;
+        const char *key;
+
+        pa = *ppa;
+        ASSERT(pa != NULL);
+
+        while ((key = asarray_get_key_no(pa, 0)) != NULL) {
+                asarray_remove(pa, key);
+        }
+
+        xfree(pa);
+        *ppa = NULL;
+        xmemchk();
+}

Added: experimental/j/Elphel333/rtp/daemon/rtp/asarray.h
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/asarray.h	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/asarray.h	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,48 @@
+/*
+ * FILE:    asarray.h
+ * AUTHORS: Orion Hodson 
+ *
+ * Associative array for strings.  Perloined from RAT settings code.
+ *
+ * Copyright (c) 1999-2000 University College London
+ * All rights reserved.
+ *
+ * $Id: asarray.h,v 1.1.1.1 2005/03/18 09:19:02 elphel Exp $
+ */
+
+#ifndef __AS_ARRAY_H
+#define __AS_ARRAY_H
+
+typedef struct _asarray asarray;
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/* Associative array for strings only.  Makes own internal copies of
+ * keys and values.
+ *
+ * Functions that return use TRUE for success and FALSE for failure.
+ * Double pointers in arguments are filled in by the function being 
+ * called.
+ */
+
+int32_t     asarray_create  (asarray **ppa);
+void        asarray_destroy (asarray **ppa);
+
+int32_t     asarray_add    (asarray *pa, const char *key, const char *value);
+void        asarray_remove (asarray *pa, const char *key);
+int32_t     asarray_lookup (asarray *pa, const char *key, char **value);
+
+/* asarray_get_key - gets key corresponding to index'th entry in
+ * internal representation, has not relation to order <key,value>
+ * tuples added in.  This function exists to provide easy way to drain
+ * array one item at a time. 
+ */
+const char* asarray_get_key_no(asarray *pa, int32_t index);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* __AS_ARRAY_H */

Added: experimental/j/Elphel333/rtp/daemon/rtp/autogen.sh
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/autogen.sh	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/autogen.sh	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,17 @@
+#!/bin/sh
+#
+echo "Generating build information using aclocal, automake and autoconf"
+echo "This may take a while ..."
+
+# Touch the timestamps on all the files since CVS messes them up
+directory=`dirname $0`
+touch $directory/configure.in
+
+# Regenerate configuration files
+aclocal
+automake --foreign --include-deps --add-missing --copy
+autoconf
+
+# Run configure for this platform
+#./configure $*
+echo "Now you are ready to run ./configure"


Property changes on: experimental/j/Elphel333/rtp/daemon/rtp/autogen.sh
___________________________________________________________________
Name: svn:executable
   + 

Added: experimental/j/Elphel333/rtp/daemon/rtp/base64.c
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/base64.c	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/base64.c	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,134 @@
+/*
+ * FILE:   base64.c
+ * AUTHOR: Colin Perkins
+ *
+ * MIME base64 encoder/decoder described in rfc1521. This code is derived
+ * from version 2.7 of the Bellcore metamail package.
+ *
+ * Copyright (c) 1998-2000 University College London
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, is permitted provided that the following conditions 
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by the Computer Science
+ *      Department at University College London
+ * 4. Neither the name of the University nor of the Department may be used
+ *    to endorse or promote products derived from this software without
+ *    specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * Copyright (c) 1991 Bell Communications Research, Inc. (Bellcore)
+ * 
+ * Permission to use, copy, modify, and distribute this material 
+ * for any purpose and without fee is hereby granted, provided 
+ * that the above copyright notice and this permission notice 
+ * appear in all copies, and that the name of Bellcore not be 
+ * used in advertising or publicity pertaining to this 
+ * material without the specific, prior written permission 
+ * of an authorized representative of Bellcore.  BELLCORE 
+ * MAKES NO REPRESENTATIONS ABOUT THE ACCURACY OR SUITABILITY 
+ * OF THIS MATERIAL FOR ANY PURPOSE.  IT IS PROVIDED "AS IS", 
+ * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
+ * 
+ */
+
+#include "config_unix.h"
+#include "config_win32.h"
+#include "debug.h"
+#include "base64.h"
+
+static unsigned char basis_64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+
+int base64encode(const unsigned char *input, int input_length, unsigned char *output, int output_length)
+{
+	int	i = 0, j = 0;
+	int	pad;
+
+	ASSERT(output_length >= (input_length * 4 / 3));
+
+	while (i < input_length) {
+		pad = 3 - (input_length - i);
+		if (pad == 2) {
+			output[j  ] = basis_64[input[i]>>2];
+			output[j+1] = basis_64[(input[i] & 0x03) << 4];
+			output[j+2] = '=';
+			output[j+3] = '=';
+		} else if (pad == 1) {
+			output[j  ] = basis_64[input[i]>>2];
+			output[j+1] = basis_64[((input[i] & 0x03) << 4) | ((input[i+1] & 0xf0) >> 4)];
+			output[j+2] = basis_64[(input[i+1] & 0x0f) << 2];
+			output[j+3] = '=';
+		} else{
+			output[j  ] = basis_64[input[i]>>2];
+			output[j+1] = basis_64[((input[i] & 0x03) << 4) | ((input[i+1] & 0xf0) >> 4)];
+			output[j+2] = basis_64[((input[i+1] & 0x0f) << 2) | ((input[i+2] & 0xc0) >> 6)];
+			output[j+3] = basis_64[input[i+2] & 0x3f];
+		}
+		i += 3;
+		j += 4;
+	}
+	return j;
+}
+
+/* This assumes that an unsigned char is exactly 8 bits. Not portable code! :-) */
+static unsigned char index_64[128] = {
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,   62, 0xff, 0xff, 0xff,   63,
+      52,   53,   54,   55,   56,   57,   58,   59,   60,   61, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff,    0,    1,    2,    3,    4,    5,    6,    7,    8,    9,   10,   11,   12,   13,   14,
+      15,   16,   17,   18,   19,   20,   21,   22,   23,   24,   25, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff,   26,   27,   28,   29,   30,   31,   32,   33,   34,   35,   36,   37,   38,   39,   40,
+      41,   42,   43,   44,   45,   46,   47,   48,   49,   50,   51, 0xff, 0xff, 0xff, 0xff, 0xff
+};
+
+#define char64(c)  ((c > 127) ? 0xff : index_64[(c)])
+
+int base64decode(const unsigned char *input, int input_length, unsigned char *output, int output_length)
+{
+	int		i = 0, j = 0, pad;
+	unsigned char	c[4];
+
+	ASSERT(output_length >= (input_length * 3 / 4));
+	ASSERT((input_length % 4) == 0);
+	while ((i + 3) < input_length) {
+		pad  = 0;
+		c[0] = char64(input[i  ]); pad += (c[0] == 0xff);
+		c[1] = char64(input[i+1]); pad += (c[1] == 0xff);
+		c[2] = char64(input[i+2]); pad += (c[2] == 0xff);
+		c[3] = char64(input[i+3]); pad += (c[3] == 0xff);
+		if (pad == 2) {
+			output[j++] = (c[0] << 2) | ((c[1] & 0x30) >> 4);
+			output[j]   = (c[1] & 0x0f) << 4;
+		} else if (pad == 1) {
+			output[j++] = (c[0] << 2) | ((c[1] & 0x30) >> 4);
+			output[j++] = ((c[1] & 0x0f) << 4) | ((c[2] & 0x3c) >> 2);
+			output[j]   = (c[2] & 0x03) << 6;
+		} else {
+			output[j++] = (c[0] << 2) | ((c[1] & 0x30) >> 4);
+			output[j++] = ((c[1] & 0x0f) << 4) | ((c[2] & 0x3c) >> 2);
+			output[j++] = ((c[2] & 0x03) << 6) | (c[3] & 0x3f);
+		}
+		i += 4;
+	}
+	return j;
+}
+

Added: experimental/j/Elphel333/rtp/daemon/rtp/base64.h
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/base64.h	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/base64.h	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,38 @@
+/*
+ * FILE:    base64.h
+ * AUTHORS: Colin Perkins
+ * 
+ * Copyright (c) 1998-2000 University College London
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, is permitted provided that the following conditions 
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by the Computer Science
+ *      Department at University College London
+ * 4. Neither the name of the University nor of the Department may be used
+ *    to endorse or promote products derived from this software without
+ *    specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+int base64encode(const unsigned char *input, int input_length, unsigned char *output, int output_length);
+int base64decode(const unsigned char *input, int input_length, unsigned char *output, int output_length);
+

Added: experimental/j/Elphel333/rtp/daemon/rtp/bills_srtp.h
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/bills_srtp.h	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/bills_srtp.h	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,10 @@
+typedef struct bills_srtp_t {
+  srtp_ctx_t sender_srtp_ctx;
+  srtp_ctx_t receiver_srtp_ctx;
+} bills_srtp_t;
+
+bills_srtp_t *srtp_init(unsigned int our_ssrc,
+			unsigned int their_ssrc,
+			unsigned char *input_key,
+			int do_encrypt,
+			int do_auth);

Added: experimental/j/Elphel333/rtp/daemon/rtp/bittypes.h
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/bittypes.h	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/bittypes.h	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 1999 WIDE Project.
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#ifndef HAVE_U_INT8_T
+
+#if SIZEOF_CHAR == 1
+typedef unsigned char u_int8_t;
+#elif SIZEOF_INT == 1
+typedef unsigned int u_int8_t;
+#else  /* XXX */
+#error "there's no appropriate type for u_int8_t"
+#endif
+
+#endif /* HAVE_U_INT8_T */
+
+#ifndef HAVE_U_INT16_T 
+
+#if SIZEOF_SHORT == 2
+typedef unsigned short u_int16_t;
+#elif SIZEOF_INT == 2
+typedef unsigned int u_int16_t;
+#elif SIZEOF_CHAR == 2
+typedef unsigned char u_int16_t;
+#else  /* XXX */
+#error "there's no appropriate type for u_int16_t"
+#endif
+
+#endif /* HAVE_U_INT16_T */
+
+#ifndef HAVE_U_INT32_T
+
+#if SIZEOF_INT == 4
+typedef unsigned int u_int32_t;
+#elif SIZEOF_LONG == 4
+typedef unsigned long u_int32_t;
+#elif SIZEOF_SHORT == 4
+typedef unsigned short u_int32_t;
+#else  /* XXX */
+#error "there's no appropriate type for u_int32_t"
+#endif
+
+#endif /* HAVE_U_INT32_T */

Added: experimental/j/Elphel333/rtp/daemon/rtp/boxes-fst.dat
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/boxes-fst.dat	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/boxes-fst.dat	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,914 @@
+static word8 S[256] = {
+ 99, 124, 119, 123, 242, 107, 111, 197,  48,   1, 103,  43, 254, 215, 171, 118, 
+202, 130, 201, 125, 250,  89,  71, 240, 173, 212, 162, 175, 156, 164, 114, 192, 
+183, 253, 147,  38,  54,  63, 247, 204,  52, 165, 229, 241, 113, 216,  49,  21, 
+  4, 199,  35, 195,  24, 150,   5, 154,   7,  18, 128, 226, 235,  39, 178, 117, 
+  9, 131,  44,  26,  27, 110,  90, 160,  82,  59, 214, 179,  41, 227,  47, 132, 
+ 83, 209,   0, 237,  32, 252, 177,  91, 106, 203, 190,  57,  74,  76,  88, 207, 
+208, 239, 170, 251,  67,  77,  51, 133,  69, 249,   2, 127,  80,  60, 159, 168, 
+ 81, 163,  64, 143, 146, 157,  56, 245, 188, 182, 218,  33,  16, 255, 243, 210, 
+205,  12,  19, 236,  95, 151,  68,  23, 196, 167, 126,  61, 100,  93,  25, 115, 
+ 96, 129,  79, 220,  34,  42, 144, 136,  70, 238, 184,  20, 222,  94,  11, 219, 
+224,  50,  58,  10,  73,   6,  36,  92, 194, 211, 172,  98, 145, 149, 228, 121, 
+231, 200,  55, 109, 141, 213,  78, 169, 108,  86, 244, 234, 101, 122, 174,   8, 
+186, 120,  37,  46,  28, 166, 180, 198, 232, 221, 116,  31,  75, 189, 139, 138, 
+112,  62, 181, 102,  72,   3, 246,  14,  97,  53,  87, 185, 134, 193,  29, 158, 
+225, 248, 152,  17, 105, 217, 142, 148, 155,  30, 135, 233, 206,  85,  40, 223, 
+140, 161, 137,  13, 191, 230,  66, 104,  65, 153,  45,  15, 176,  84, 187,  22
+};
+
+#ifdef INTERMEDIATE_VALUE_KAT
+static word8 Si[256] = {
+ 82,   9, 106, 213,  48,  54, 165,  56, 191,  64, 163, 158, 129, 243, 215, 251, 
+124, 227,  57, 130, 155,  47, 255, 135,  52, 142,  67,  68, 196, 222, 233, 203, 
+ 84, 123, 148,  50, 166, 194,  35,  61, 238,  76, 149,  11,  66, 250, 195,  78, 
+  8,  46, 161, 102,  40, 217,  36, 178, 118,  91, 162,  73, 109, 139, 209,  37, 
+114, 248, 246, 100, 134, 104, 152,  22, 212, 164,  92, 204,  93, 101, 182, 146, 
+108, 112,  72,  80, 253, 237, 185, 218,  94,  21,  70,  87, 167, 141, 157, 132, 
+144, 216, 171,   0, 140, 188, 211,  10, 247, 228,  88,   5, 184, 179,  69,   6, 
+208,  44,  30, 143, 202,  63,  15,   2, 193, 175, 189,   3,   1,  19, 138, 107, 
+ 58, 145,  17,  65,  79, 103, 220, 234, 151, 242, 207, 206, 240, 180, 230, 115, 
+150, 172, 116,  34, 231, 173,  53, 133, 226, 249,  55, 232,  28, 117, 223, 110, 
+ 71, 241,  26, 113,  29,  41, 197, 137, 111, 183,  98,  14, 170,  24, 190,  27, 
+252,  86,  62,  75, 198, 210, 121,  32, 154, 219, 192, 254, 120, 205,  90, 244, 
+ 31, 221, 168,  51, 136,   7, 199,  49, 177,  18,  16,  89,  39, 128, 236,  95, 
+ 96,  81, 127, 169,  25, 181,  74,  13,  45, 229, 122, 159, 147, 201, 156, 239, 
+160, 224,  59,  77, 174,  42, 245, 176, 200, 235, 187,  60, 131,  83, 153,  97, 
+ 23,  43,   4, 126, 186, 119, 214,  38, 225, 105,  20,  99,  85,  33,  12, 125
+};
+#endif /* INTERMEDIATE_VALUE_KAT */
+
+static word8 T1[256][4] = {
+{0xc6,0x63,0x63,0xa5}, {0xf8,0x7c,0x7c,0x84}, {0xee,0x77,0x77,0x99}, {0xf6,0x7b,0x7b,0x8d}, 
+{0xff,0xf2,0xf2,0x0d}, {0xd6,0x6b,0x6b,0xbd}, {0xde,0x6f,0x6f,0xb1}, {0x91,0xc5,0xc5,0x54}, 
+{0x60,0x30,0x30,0x50}, {0x02,0x01,0x01,0x03}, {0xce,0x67,0x67,0xa9}, {0x56,0x2b,0x2b,0x7d}, 
+{0xe7,0xfe,0xfe,0x19}, {0xb5,0xd7,0xd7,0x62}, {0x4d,0xab,0xab,0xe6}, {0xec,0x76,0x76,0x9a}, 
+{0x8f,0xca,0xca,0x45}, {0x1f,0x82,0x82,0x9d}, {0x89,0xc9,0xc9,0x40}, {0xfa,0x7d,0x7d,0x87}, 
+{0xef,0xfa,0xfa,0x15}, {0xb2,0x59,0x59,0xeb}, {0x8e,0x47,0x47,0xc9}, {0xfb,0xf0,0xf0,0x0b}, 
+{0x41,0xad,0xad,0xec}, {0xb3,0xd4,0xd4,0x67}, {0x5f,0xa2,0xa2,0xfd}, {0x45,0xaf,0xaf,0xea}, 
+{0x23,0x9c,0x9c,0xbf}, {0x53,0xa4,0xa4,0xf7}, {0xe4,0x72,0x72,0x96}, {0x9b,0xc0,0xc0,0x5b}, 
+{0x75,0xb7,0xb7,0xc2}, {0xe1,0xfd,0xfd,0x1c}, {0x3d,0x93,0x93,0xae}, {0x4c,0x26,0x26,0x6a}, 
+{0x6c,0x36,0x36,0x5a}, {0x7e,0x3f,0x3f,0x41}, {0xf5,0xf7,0xf7,0x02}, {0x83,0xcc,0xcc,0x4f}, 
+{0x68,0x34,0x34,0x5c}, {0x51,0xa5,0xa5,0xf4}, {0xd1,0xe5,0xe5,0x34}, {0xf9,0xf1,0xf1,0x08}, 
+{0xe2,0x71,0x71,0x93}, {0xab,0xd8,0xd8,0x73}, {0x62,0x31,0x31,0x53}, {0x2a,0x15,0x15,0x3f}, 
+{0x08,0x04,0x04,0x0c}, {0x95,0xc7,0xc7,0x52}, {0x46,0x23,0x23,0x65}, {0x9d,0xc3,0xc3,0x5e}, 
+{0x30,0x18,0x18,0x28}, {0x37,0x96,0x96,0xa1}, {0x0a,0x05,0x05,0x0f}, {0x2f,0x9a,0x9a,0xb5}, 
+{0x0e,0x07,0x07,0x09}, {0x24,0x12,0x12,0x36}, {0x1b,0x80,0x80,0x9b}, {0xdf,0xe2,0xe2,0x3d}, 
+{0xcd,0xeb,0xeb,0x26}, {0x4e,0x27,0x27,0x69}, {0x7f,0xb2,0xb2,0xcd}, {0xea,0x75,0x75,0x9f}, 
+{0x12,0x09,0x09,0x1b}, {0x1d,0x83,0x83,0x9e}, {0x58,0x2c,0x2c,0x74}, {0x34,0x1a,0x1a,0x2e}, 
+{0x36,0x1b,0x1b,0x2d}, {0xdc,0x6e,0x6e,0xb2}, {0xb4,0x5a,0x5a,0xee}, {0x5b,0xa0,0xa0,0xfb}, 
+{0xa4,0x52,0x52,0xf6}, {0x76,0x3b,0x3b,0x4d}, {0xb7,0xd6,0xd6,0x61}, {0x7d,0xb3,0xb3,0xce}, 
+{0x52,0x29,0x29,0x7b}, {0xdd,0xe3,0xe3,0x3e}, {0x5e,0x2f,0x2f,0x71}, {0x13,0x84,0x84,0x97}, 
+{0xa6,0x53,0x53,0xf5}, {0xb9,0xd1,0xd1,0x68}, {0x00,0x00,0x00,0x00}, {0xc1,0xed,0xed,0x2c}, 
+{0x40,0x20,0x20,0x60}, {0xe3,0xfc,0xfc,0x1f}, {0x79,0xb1,0xb1,0xc8}, {0xb6,0x5b,0x5b,0xed}, 
+{0xd4,0x6a,0x6a,0xbe}, {0x8d,0xcb,0xcb,0x46}, {0x67,0xbe,0xbe,0xd9}, {0x72,0x39,0x39,0x4b}, 
+{0x94,0x4a,0x4a,0xde}, {0x98,0x4c,0x4c,0xd4}, {0xb0,0x58,0x58,0xe8}, {0x85,0xcf,0xcf,0x4a}, 
+{0xbb,0xd0,0xd0,0x6b}, {0xc5,0xef,0xef,0x2a}, {0x4f,0xaa,0xaa,0xe5}, {0xed,0xfb,0xfb,0x16}, 
+{0x86,0x43,0x43,0xc5}, {0x9a,0x4d,0x4d,0xd7}, {0x66,0x33,0x33,0x55}, {0x11,0x85,0x85,0x94}, 
+{0x8a,0x45,0x45,0xcf}, {0xe9,0xf9,0xf9,0x10}, {0x04,0x02,0x02,0x06}, {0xfe,0x7f,0x7f,0x81}, 
+{0xa0,0x50,0x50,0xf0}, {0x78,0x3c,0x3c,0x44}, {0x25,0x9f,0x9f,0xba}, {0x4b,0xa8,0xa8,0xe3}, 
+{0xa2,0x51,0x51,0xf3}, {0x5d,0xa3,0xa3,0xfe}, {0x80,0x40,0x40,0xc0}, {0x05,0x8f,0x8f,0x8a}, 
+{0x3f,0x92,0x92,0xad}, {0x21,0x9d,0x9d,0xbc}, {0x70,0x38,0x38,0x48}, {0xf1,0xf5,0xf5,0x04}, 
+{0x63,0xbc,0xbc,0xdf}, {0x77,0xb6,0xb6,0xc1}, {0xaf,0xda,0xda,0x75}, {0x42,0x21,0x21,0x63}, 
+{0x20,0x10,0x10,0x30}, {0xe5,0xff,0xff,0x1a}, {0xfd,0xf3,0xf3,0x0e}, {0xbf,0xd2,0xd2,0x6d}, 
+{0x81,0xcd,0xcd,0x4c}, {0x18,0x0c,0x0c,0x14}, {0x26,0x13,0x13,0x35}, {0xc3,0xec,0xec,0x2f}, 
+{0xbe,0x5f,0x5f,0xe1}, {0x35,0x97,0x97,0xa2}, {0x88,0x44,0x44,0xcc}, {0x2e,0x17,0x17,0x39}, 
+{0x93,0xc4,0xc4,0x57}, {0x55,0xa7,0xa7,0xf2}, {0xfc,0x7e,0x7e,0x82}, {0x7a,0x3d,0x3d,0x47}, 
+{0xc8,0x64,0x64,0xac}, {0xba,0x5d,0x5d,0xe7}, {0x32,0x19,0x19,0x2b}, {0xe6,0x73,0x73,0x95}, 
+{0xc0,0x60,0x60,0xa0}, {0x19,0x81,0x81,0x98}, {0x9e,0x4f,0x4f,0xd1}, {0xa3,0xdc,0xdc,0x7f}, 
+{0x44,0x22,0x22,0x66}, {0x54,0x2a,0x2a,0x7e}, {0x3b,0x90,0x90,0xab}, {0x0b,0x88,0x88,0x83}, 
+{0x8c,0x46,0x46,0xca}, {0xc7,0xee,0xee,0x29}, {0x6b,0xb8,0xb8,0xd3}, {0x28,0x14,0x14,0x3c}, 
+{0xa7,0xde,0xde,0x79}, {0xbc,0x5e,0x5e,0xe2}, {0x16,0x0b,0x0b,0x1d}, {0xad,0xdb,0xdb,0x76}, 
+{0xdb,0xe0,0xe0,0x3b}, {0x64,0x32,0x32,0x56}, {0x74,0x3a,0x3a,0x4e}, {0x14,0x0a,0x0a,0x1e}, 
+{0x92,0x49,0x49,0xdb}, {0x0c,0x06,0x06,0x0a}, {0x48,0x24,0x24,0x6c}, {0xb8,0x5c,0x5c,0xe4}, 
+{0x9f,0xc2,0xc2,0x5d}, {0xbd,0xd3,0xd3,0x6e}, {0x43,0xac,0xac,0xef}, {0xc4,0x62,0x62,0xa6}, 
+{0x39,0x91,0x91,0xa8}, {0x31,0x95,0x95,0xa4}, {0xd3,0xe4,0xe4,0x37}, {0xf2,0x79,0x79,0x8b}, 
+{0xd5,0xe7,0xe7,0x32}, {0x8b,0xc8,0xc8,0x43}, {0x6e,0x37,0x37,0x59}, {0xda,0x6d,0x6d,0xb7}, 
+{0x01,0x8d,0x8d,0x8c}, {0xb1,0xd5,0xd5,0x64}, {0x9c,0x4e,0x4e,0xd2}, {0x49,0xa9,0xa9,0xe0}, 
+{0xd8,0x6c,0x6c,0xb4}, {0xac,0x56,0x56,0xfa}, {0xf3,0xf4,0xf4,0x07}, {0xcf,0xea,0xea,0x25}, 
+{0xca,0x65,0x65,0xaf}, {0xf4,0x7a,0x7a,0x8e}, {0x47,0xae,0xae,0xe9}, {0x10,0x08,0x08,0x18}, 
+{0x6f,0xba,0xba,0xd5}, {0xf0,0x78,0x78,0x88}, {0x4a,0x25,0x25,0x6f}, {0x5c,0x2e,0x2e,0x72}, 
+{0x38,0x1c,0x1c,0x24}, {0x57,0xa6,0xa6,0xf1}, {0x73,0xb4,0xb4,0xc7}, {0x97,0xc6,0xc6,0x51}, 
+{0xcb,0xe8,0xe8,0x23}, {0xa1,0xdd,0xdd,0x7c}, {0xe8,0x74,0x74,0x9c}, {0x3e,0x1f,0x1f,0x21}, 
+{0x96,0x4b,0x4b,0xdd}, {0x61,0xbd,0xbd,0xdc}, {0x0d,0x8b,0x8b,0x86}, {0x0f,0x8a,0x8a,0x85}, 
+{0xe0,0x70,0x70,0x90}, {0x7c,0x3e,0x3e,0x42}, {0x71,0xb5,0xb5,0xc4}, {0xcc,0x66,0x66,0xaa}, 
+{0x90,0x48,0x48,0xd8}, {0x06,0x03,0x03,0x05}, {0xf7,0xf6,0xf6,0x01}, {0x1c,0x0e,0x0e,0x12}, 
+{0xc2,0x61,0x61,0xa3}, {0x6a,0x35,0x35,0x5f}, {0xae,0x57,0x57,0xf9}, {0x69,0xb9,0xb9,0xd0}, 
+{0x17,0x86,0x86,0x91}, {0x99,0xc1,0xc1,0x58}, {0x3a,0x1d,0x1d,0x27}, {0x27,0x9e,0x9e,0xb9}, 
+{0xd9,0xe1,0xe1,0x38}, {0xeb,0xf8,0xf8,0x13}, {0x2b,0x98,0x98,0xb3}, {0x22,0x11,0x11,0x33}, 
+{0xd2,0x69,0x69,0xbb}, {0xa9,0xd9,0xd9,0x70}, {0x07,0x8e,0x8e,0x89}, {0x33,0x94,0x94,0xa7}, 
+{0x2d,0x9b,0x9b,0xb6}, {0x3c,0x1e,0x1e,0x22}, {0x15,0x87,0x87,0x92}, {0xc9,0xe9,0xe9,0x20}, 
+{0x87,0xce,0xce,0x49}, {0xaa,0x55,0x55,0xff}, {0x50,0x28,0x28,0x78}, {0xa5,0xdf,0xdf,0x7a}, 
+{0x03,0x8c,0x8c,0x8f}, {0x59,0xa1,0xa1,0xf8}, {0x09,0x89,0x89,0x80}, {0x1a,0x0d,0x0d,0x17}, 
+{0x65,0xbf,0xbf,0xda}, {0xd7,0xe6,0xe6,0x31}, {0x84,0x42,0x42,0xc6}, {0xd0,0x68,0x68,0xb8}, 
+{0x82,0x41,0x41,0xc3}, {0x29,0x99,0x99,0xb0}, {0x5a,0x2d,0x2d,0x77}, {0x1e,0x0f,0x0f,0x11}, 
+{0x7b,0xb0,0xb0,0xcb}, {0xa8,0x54,0x54,0xfc}, {0x6d,0xbb,0xbb,0xd6}, {0x2c,0x16,0x16,0x3a}
+};
+
+static word8 T2[256][4] = {
+{0xa5,0xc6,0x63,0x63}, {0x84,0xf8,0x7c,0x7c}, {0x99,0xee,0x77,0x77}, {0x8d,0xf6,0x7b,0x7b}, 
+{0x0d,0xff,0xf2,0xf2}, {0xbd,0xd6,0x6b,0x6b}, {0xb1,0xde,0x6f,0x6f}, {0x54,0x91,0xc5,0xc5}, 
+{0x50,0x60,0x30,0x30}, {0x03,0x02,0x01,0x01}, {0xa9,0xce,0x67,0x67}, {0x7d,0x56,0x2b,0x2b}, 
+{0x19,0xe7,0xfe,0xfe}, {0x62,0xb5,0xd7,0xd7}, {0xe6,0x4d,0xab,0xab}, {0x9a,0xec,0x76,0x76}, 
+{0x45,0x8f,0xca,0xca}, {0x9d,0x1f,0x82,0x82}, {0x40,0x89,0xc9,0xc9}, {0x87,0xfa,0x7d,0x7d}, 
+{0x15,0xef,0xfa,0xfa}, {0xeb,0xb2,0x59,0x59}, {0xc9,0x8e,0x47,0x47}, {0x0b,0xfb,0xf0,0xf0}, 
+{0xec,0x41,0xad,0xad}, {0x67,0xb3,0xd4,0xd4}, {0xfd,0x5f,0xa2,0xa2}, {0xea,0x45,0xaf,0xaf}, 
+{0xbf,0x23,0x9c,0x9c}, {0xf7,0x53,0xa4,0xa4}, {0x96,0xe4,0x72,0x72}, {0x5b,0x9b,0xc0,0xc0}, 
+{0xc2,0x75,0xb7,0xb7}, {0x1c,0xe1,0xfd,0xfd}, {0xae,0x3d,0x93,0x93}, {0x6a,0x4c,0x26,0x26}, 
+{0x5a,0x6c,0x36,0x36}, {0x41,0x7e,0x3f,0x3f}, {0x02,0xf5,0xf7,0xf7}, {0x4f,0x83,0xcc,0xcc}, 
+{0x5c,0x68,0x34,0x34}, {0xf4,0x51,0xa5,0xa5}, {0x34,0xd1,0xe5,0xe5}, {0x08,0xf9,0xf1,0xf1}, 
+{0x93,0xe2,0x71,0x71}, {0x73,0xab,0xd8,0xd8}, {0x53,0x62,0x31,0x31}, {0x3f,0x2a,0x15,0x15}, 
+{0x0c,0x08,0x04,0x04}, {0x52,0x95,0xc7,0xc7}, {0x65,0x46,0x23,0x23}, {0x5e,0x9d,0xc3,0xc3}, 
+{0x28,0x30,0x18,0x18}, {0xa1,0x37,0x96,0x96}, {0x0f,0x0a,0x05,0x05}, {0xb5,0x2f,0x9a,0x9a}, 
+{0x09,0x0e,0x07,0x07}, {0x36,0x24,0x12,0x12}, {0x9b,0x1b,0x80,0x80}, {0x3d,0xdf,0xe2,0xe2}, 
+{0x26,0xcd,0xeb,0xeb}, {0x69,0x4e,0x27,0x27}, {0xcd,0x7f,0xb2,0xb2}, {0x9f,0xea,0x75,0x75}, 
+{0x1b,0x12,0x09,0x09}, {0x9e,0x1d,0x83,0x83}, {0x74,0x58,0x2c,0x2c}, {0x2e,0x34,0x1a,0x1a}, 
+{0x2d,0x36,0x1b,0x1b}, {0xb2,0xdc,0x6e,0x6e}, {0xee,0xb4,0x5a,0x5a}, {0xfb,0x5b,0xa0,0xa0}, 
+{0xf6,0xa4,0x52,0x52}, {0x4d,0x76,0x3b,0x3b}, {0x61,0xb7,0xd6,0xd6}, {0xce,0x7d,0xb3,0xb3}, 
+{0x7b,0x52,0x29,0x29}, {0x3e,0xdd,0xe3,0xe3}, {0x71,0x5e,0x2f,0x2f}, {0x97,0x13,0x84,0x84}, 
+{0xf5,0xa6,0x53,0x53}, {0x68,0xb9,0xd1,0xd1}, {0x00,0x00,0x00,0x00}, {0x2c,0xc1,0xed,0xed}, 
+{0x60,0x40,0x20,0x20}, {0x1f,0xe3,0xfc,0xfc}, {0xc8,0x79,0xb1,0xb1}, {0xed,0xb6,0x5b,0x5b}, 
+{0xbe,0xd4,0x6a,0x6a}, {0x46,0x8d,0xcb,0xcb}, {0xd9,0x67,0xbe,0xbe}, {0x4b,0x72,0x39,0x39}, 
+{0xde,0x94,0x4a,0x4a}, {0xd4,0x98,0x4c,0x4c}, {0xe8,0xb0,0x58,0x58}, {0x4a,0x85,0xcf,0xcf}, 
+{0x6b,0xbb,0xd0,0xd0}, {0x2a,0xc5,0xef,0xef}, {0xe5,0x4f,0xaa,0xaa}, {0x16,0xed,0xfb,0xfb}, 
+{0xc5,0x86,0x43,0x43}, {0xd7,0x9a,0x4d,0x4d}, {0x55,0x66,0x33,0x33}, {0x94,0x11,0x85,0x85}, 
+{0xcf,0x8a,0x45,0x45}, {0x10,0xe9,0xf9,0xf9}, {0x06,0x04,0x02,0x02}, {0x81,0xfe,0x7f,0x7f}, 
+{0xf0,0xa0,0x50,0x50}, {0x44,0x78,0x3c,0x3c}, {0xba,0x25,0x9f,0x9f}, {0xe3,0x4b,0xa8,0xa8}, 
+{0xf3,0xa2,0x51,0x51}, {0xfe,0x5d,0xa3,0xa3}, {0xc0,0x80,0x40,0x40}, {0x8a,0x05,0x8f,0x8f}, 
+{0xad,0x3f,0x92,0x92}, {0xbc,0x21,0x9d,0x9d}, {0x48,0x70,0x38,0x38}, {0x04,0xf1,0xf5,0xf5}, 
+{0xdf,0x63,0xbc,0xbc}, {0xc1,0x77,0xb6,0xb6}, {0x75,0xaf,0xda,0xda}, {0x63,0x42,0x21,0x21}, 
+{0x30,0x20,0x10,0x10}, {0x1a,0xe5,0xff,0xff}, {0x0e,0xfd,0xf3,0xf3}, {0x6d,0xbf,0xd2,0xd2}, 
+{0x4c,0x81,0xcd,0xcd}, {0x14,0x18,0x0c,0x0c}, {0x35,0x26,0x13,0x13}, {0x2f,0xc3,0xec,0xec}, 
+{0xe1,0xbe,0x5f,0x5f}, {0xa2,0x35,0x97,0x97}, {0xcc,0x88,0x44,0x44}, {0x39,0x2e,0x17,0x17}, 
+{0x57,0x93,0xc4,0xc4}, {0xf2,0x55,0xa7,0xa7}, {0x82,0xfc,0x7e,0x7e}, {0x47,0x7a,0x3d,0x3d}, 
+{0xac,0xc8,0x64,0x64}, {0xe7,0xba,0x5d,0x5d}, {0x2b,0x32,0x19,0x19}, {0x95,0xe6,0x73,0x73}, 
+{0xa0,0xc0,0x60,0x60}, {0x98,0x19,0x81,0x81}, {0xd1,0x9e,0x4f,0x4f}, {0x7f,0xa3,0xdc,0xdc}, 
+{0x66,0x44,0x22,0x22}, {0x7e,0x54,0x2a,0x2a}, {0xab,0x3b,0x90,0x90}, {0x83,0x0b,0x88,0x88}, 
+{0xca,0x8c,0x46,0x46}, {0x29,0xc7,0xee,0xee}, {0xd3,0x6b,0xb8,0xb8}, {0x3c,0x28,0x14,0x14}, 
+{0x79,0xa7,0xde,0xde}, {0xe2,0xbc,0x5e,0x5e}, {0x1d,0x16,0x0b,0x0b}, {0x76,0xad,0xdb,0xdb}, 
+{0x3b,0xdb,0xe0,0xe0}, {0x56,0x64,0x32,0x32}, {0x4e,0x74,0x3a,0x3a}, {0x1e,0x14,0x0a,0x0a}, 
+{0xdb,0x92,0x49,0x49}, {0x0a,0x0c,0x06,0x06}, {0x6c,0x48,0x24,0x24}, {0xe4,0xb8,0x5c,0x5c}, 
+{0x5d,0x9f,0xc2,0xc2}, {0x6e,0xbd,0xd3,0xd3}, {0xef,0x43,0xac,0xac}, {0xa6,0xc4,0x62,0x62}, 
+{0xa8,0x39,0x91,0x91}, {0xa4,0x31,0x95,0x95}, {0x37,0xd3,0xe4,0xe4}, {0x8b,0xf2,0x79,0x79}, 
+{0x32,0xd5,0xe7,0xe7}, {0x43,0x8b,0xc8,0xc8}, {0x59,0x6e,0x37,0x37}, {0xb7,0xda,0x6d,0x6d}, 
+{0x8c,0x01,0x8d,0x8d}, {0x64,0xb1,0xd5,0xd5}, {0xd2,0x9c,0x4e,0x4e}, {0xe0,0x49,0xa9,0xa9}, 
+{0xb4,0xd8,0x6c,0x6c}, {0xfa,0xac,0x56,0x56}, {0x07,0xf3,0xf4,0xf4}, {0x25,0xcf,0xea,0xea}, 
+{0xaf,0xca,0x65,0x65}, {0x8e,0xf4,0x7a,0x7a}, {0xe9,0x47,0xae,0xae}, {0x18,0x10,0x08,0x08}, 
+{0xd5,0x6f,0xba,0xba}, {0x88,0xf0,0x78,0x78}, {0x6f,0x4a,0x25,0x25}, {0x72,0x5c,0x2e,0x2e}, 
+{0x24,0x38,0x1c,0x1c}, {0xf1,0x57,0xa6,0xa6}, {0xc7,0x73,0xb4,0xb4}, {0x51,0x97,0xc6,0xc6}, 
+{0x23,0xcb,0xe8,0xe8}, {0x7c,0xa1,0xdd,0xdd}, {0x9c,0xe8,0x74,0x74}, {0x21,0x3e,0x1f,0x1f}, 
+{0xdd,0x96,0x4b,0x4b}, {0xdc,0x61,0xbd,0xbd}, {0x86,0x0d,0x8b,0x8b}, {0x85,0x0f,0x8a,0x8a}, 
+{0x90,0xe0,0x70,0x70}, {0x42,0x7c,0x3e,0x3e}, {0xc4,0x71,0xb5,0xb5}, {0xaa,0xcc,0x66,0x66}, 
+{0xd8,0x90,0x48,0x48}, {0x05,0x06,0x03,0x03}, {0x01,0xf7,0xf6,0xf6}, {0x12,0x1c,0x0e,0x0e}, 
+{0xa3,0xc2,0x61,0x61}, {0x5f,0x6a,0x35,0x35}, {0xf9,0xae,0x57,0x57}, {0xd0,0x69,0xb9,0xb9}, 
+{0x91,0x17,0x86,0x86}, {0x58,0x99,0xc1,0xc1}, {0x27,0x3a,0x1d,0x1d}, {0xb9,0x27,0x9e,0x9e}, 
+{0x38,0xd9,0xe1,0xe1}, {0x13,0xeb,0xf8,0xf8}, {0xb3,0x2b,0x98,0x98}, {0x33,0x22,0x11,0x11}, 
+{0xbb,0xd2,0x69,0x69}, {0x70,0xa9,0xd9,0xd9}, {0x89,0x07,0x8e,0x8e}, {0xa7,0x33,0x94,0x94}, 
+{0xb6,0x2d,0x9b,0x9b}, {0x22,0x3c,0x1e,0x1e}, {0x92,0x15,0x87,0x87}, {0x20,0xc9,0xe9,0xe9}, 
+{0x49,0x87,0xce,0xce}, {0xff,0xaa,0x55,0x55}, {0x78,0x50,0x28,0x28}, {0x7a,0xa5,0xdf,0xdf}, 
+{0x8f,0x03,0x8c,0x8c}, {0xf8,0x59,0xa1,0xa1}, {0x80,0x09,0x89,0x89}, {0x17,0x1a,0x0d,0x0d}, 
+{0xda,0x65,0xbf,0xbf}, {0x31,0xd7,0xe6,0xe6}, {0xc6,0x84,0x42,0x42}, {0xb8,0xd0,0x68,0x68}, 
+{0xc3,0x82,0x41,0x41}, {0xb0,0x29,0x99,0x99}, {0x77,0x5a,0x2d,0x2d}, {0x11,0x1e,0x0f,0x0f}, 
+{0xcb,0x7b,0xb0,0xb0}, {0xfc,0xa8,0x54,0x54}, {0xd6,0x6d,0xbb,0xbb}, {0x3a,0x2c,0x16,0x16}
+};
+
+static word8 T3[256][4] = {
+{0x63,0xa5,0xc6,0x63}, {0x7c,0x84,0xf8,0x7c}, {0x77,0x99,0xee,0x77}, {0x7b,0x8d,0xf6,0x7b}, 
+{0xf2,0x0d,0xff,0xf2}, {0x6b,0xbd,0xd6,0x6b}, {0x6f,0xb1,0xde,0x6f}, {0xc5,0x54,0x91,0xc5}, 
+{0x30,0x50,0x60,0x30}, {0x01,0x03,0x02,0x01}, {0x67,0xa9,0xce,0x67}, {0x2b,0x7d,0x56,0x2b}, 
+{0xfe,0x19,0xe7,0xfe}, {0xd7,0x62,0xb5,0xd7}, {0xab,0xe6,0x4d,0xab}, {0x76,0x9a,0xec,0x76}, 
+{0xca,0x45,0x8f,0xca}, {0x82,0x9d,0x1f,0x82}, {0xc9,0x40,0x89,0xc9}, {0x7d,0x87,0xfa,0x7d}, 
+{0xfa,0x15,0xef,0xfa}, {0x59,0xeb,0xb2,0x59}, {0x47,0xc9,0x8e,0x47}, {0xf0,0x0b,0xfb,0xf0}, 
+{0xad,0xec,0x41,0xad}, {0xd4,0x67,0xb3,0xd4}, {0xa2,0xfd,0x5f,0xa2}, {0xaf,0xea,0x45,0xaf}, 
+{0x9c,0xbf,0x23,0x9c}, {0xa4,0xf7,0x53,0xa4}, {0x72,0x96,0xe4,0x72}, {0xc0,0x5b,0x9b,0xc0}, 
+{0xb7,0xc2,0x75,0xb7}, {0xfd,0x1c,0xe1,0xfd}, {0x93,0xae,0x3d,0x93}, {0x26,0x6a,0x4c,0x26}, 
+{0x36,0x5a,0x6c,0x36}, {0x3f,0x41,0x7e,0x3f}, {0xf7,0x02,0xf5,0xf7}, {0xcc,0x4f,0x83,0xcc}, 
+{0x34,0x5c,0x68,0x34}, {0xa5,0xf4,0x51,0xa5}, {0xe5,0x34,0xd1,0xe5}, {0xf1,0x08,0xf9,0xf1}, 
+{0x71,0x93,0xe2,0x71}, {0xd8,0x73,0xab,0xd8}, {0x31,0x53,0x62,0x31}, {0x15,0x3f,0x2a,0x15}, 
+{0x04,0x0c,0x08,0x04}, {0xc7,0x52,0x95,0xc7}, {0x23,0x65,0x46,0x23}, {0xc3,0x5e,0x9d,0xc3}, 
+{0x18,0x28,0x30,0x18}, {0x96,0xa1,0x37,0x96}, {0x05,0x0f,0x0a,0x05}, {0x9a,0xb5,0x2f,0x9a}, 
+{0x07,0x09,0x0e,0x07}, {0x12,0x36,0x24,0x12}, {0x80,0x9b,0x1b,0x80}, {0xe2,0x3d,0xdf,0xe2}, 
+{0xeb,0x26,0xcd,0xeb}, {0x27,0x69,0x4e,0x27}, {0xb2,0xcd,0x7f,0xb2}, {0x75,0x9f,0xea,0x75}, 
+{0x09,0x1b,0x12,0x09}, {0x83,0x9e,0x1d,0x83}, {0x2c,0x74,0x58,0x2c}, {0x1a,0x2e,0x34,0x1a}, 
+{0x1b,0x2d,0x36,0x1b}, {0x6e,0xb2,0xdc,0x6e}, {0x5a,0xee,0xb4,0x5a}, {0xa0,0xfb,0x5b,0xa0}, 
+{0x52,0xf6,0xa4,0x52}, {0x3b,0x4d,0x76,0x3b}, {0xd6,0x61,0xb7,0xd6}, {0xb3,0xce,0x7d,0xb3}, 
+{0x29,0x7b,0x52,0x29}, {0xe3,0x3e,0xdd,0xe3}, {0x2f,0x71,0x5e,0x2f}, {0x84,0x97,0x13,0x84}, 
+{0x53,0xf5,0xa6,0x53}, {0xd1,0x68,0xb9,0xd1}, {0x00,0x00,0x00,0x00}, {0xed,0x2c,0xc1,0xed}, 
+{0x20,0x60,0x40,0x20}, {0xfc,0x1f,0xe3,0xfc}, {0xb1,0xc8,0x79,0xb1}, {0x5b,0xed,0xb6,0x5b}, 
+{0x6a,0xbe,0xd4,0x6a}, {0xcb,0x46,0x8d,0xcb}, {0xbe,0xd9,0x67,0xbe}, {0x39,0x4b,0x72,0x39}, 
+{0x4a,0xde,0x94,0x4a}, {0x4c,0xd4,0x98,0x4c}, {0x58,0xe8,0xb0,0x58}, {0xcf,0x4a,0x85,0xcf}, 
+{0xd0,0x6b,0xbb,0xd0}, {0xef,0x2a,0xc5,0xef}, {0xaa,0xe5,0x4f,0xaa}, {0xfb,0x16,0xed,0xfb}, 
+{0x43,0xc5,0x86,0x43}, {0x4d,0xd7,0x9a,0x4d}, {0x33,0x55,0x66,0x33}, {0x85,0x94,0x11,0x85}, 
+{0x45,0xcf,0x8a,0x45}, {0xf9,0x10,0xe9,0xf9}, {0x02,0x06,0x04,0x02}, {0x7f,0x81,0xfe,0x7f}, 
+{0x50,0xf0,0xa0,0x50}, {0x3c,0x44,0x78,0x3c}, {0x9f,0xba,0x25,0x9f}, {0xa8,0xe3,0x4b,0xa8}, 
+{0x51,0xf3,0xa2,0x51}, {0xa3,0xfe,0x5d,0xa3}, {0x40,0xc0,0x80,0x40}, {0x8f,0x8a,0x05,0x8f}, 
+{0x92,0xad,0x3f,0x92}, {0x9d,0xbc,0x21,0x9d}, {0x38,0x48,0x70,0x38}, {0xf5,0x04,0xf1,0xf5}, 
+{0xbc,0xdf,0x63,0xbc}, {0xb6,0xc1,0x77,0xb6}, {0xda,0x75,0xaf,0xda}, {0x21,0x63,0x42,0x21}, 
+{0x10,0x30,0x20,0x10}, {0xff,0x1a,0xe5,0xff}, {0xf3,0x0e,0xfd,0xf3}, {0xd2,0x6d,0xbf,0xd2}, 
+{0xcd,0x4c,0x81,0xcd}, {0x0c,0x14,0x18,0x0c}, {0x13,0x35,0x26,0x13}, {0xec,0x2f,0xc3,0xec}, 
+{0x5f,0xe1,0xbe,0x5f}, {0x97,0xa2,0x35,0x97}, {0x44,0xcc,0x88,0x44}, {0x17,0x39,0x2e,0x17}, 
+{0xc4,0x57,0x93,0xc4}, {0xa7,0xf2,0x55,0xa7}, {0x7e,0x82,0xfc,0x7e}, {0x3d,0x47,0x7a,0x3d}, 
+{0x64,0xac,0xc8,0x64}, {0x5d,0xe7,0xba,0x5d}, {0x19,0x2b,0x32,0x19}, {0x73,0x95,0xe6,0x73}, 
+{0x60,0xa0,0xc0,0x60}, {0x81,0x98,0x19,0x81}, {0x4f,0xd1,0x9e,0x4f}, {0xdc,0x7f,0xa3,0xdc}, 
+{0x22,0x66,0x44,0x22}, {0x2a,0x7e,0x54,0x2a}, {0x90,0xab,0x3b,0x90}, {0x88,0x83,0x0b,0x88}, 
+{0x46,0xca,0x8c,0x46}, {0xee,0x29,0xc7,0xee}, {0xb8,0xd3,0x6b,0xb8}, {0x14,0x3c,0x28,0x14}, 
+{0xde,0x79,0xa7,0xde}, {0x5e,0xe2,0xbc,0x5e}, {0x0b,0x1d,0x16,0x0b}, {0xdb,0x76,0xad,0xdb}, 
+{0xe0,0x3b,0xdb,0xe0}, {0x32,0x56,0x64,0x32}, {0x3a,0x4e,0x74,0x3a}, {0x0a,0x1e,0x14,0x0a}, 
+{0x49,0xdb,0x92,0x49}, {0x06,0x0a,0x0c,0x06}, {0x24,0x6c,0x48,0x24}, {0x5c,0xe4,0xb8,0x5c}, 
+{0xc2,0x5d,0x9f,0xc2}, {0xd3,0x6e,0xbd,0xd3}, {0xac,0xef,0x43,0xac}, {0x62,0xa6,0xc4,0x62}, 
+{0x91,0xa8,0x39,0x91}, {0x95,0xa4,0x31,0x95}, {0xe4,0x37,0xd3,0xe4}, {0x79,0x8b,0xf2,0x79}, 
+{0xe7,0x32,0xd5,0xe7}, {0xc8,0x43,0x8b,0xc8}, {0x37,0x59,0x6e,0x37}, {0x6d,0xb7,0xda,0x6d}, 
+{0x8d,0x8c,0x01,0x8d}, {0xd5,0x64,0xb1,0xd5}, {0x4e,0xd2,0x9c,0x4e}, {0xa9,0xe0,0x49,0xa9}, 
+{0x6c,0xb4,0xd8,0x6c}, {0x56,0xfa,0xac,0x56}, {0xf4,0x07,0xf3,0xf4}, {0xea,0x25,0xcf,0xea}, 
+{0x65,0xaf,0xca,0x65}, {0x7a,0x8e,0xf4,0x7a}, {0xae,0xe9,0x47,0xae}, {0x08,0x18,0x10,0x08}, 
+{0xba,0xd5,0x6f,0xba}, {0x78,0x88,0xf0,0x78}, {0x25,0x6f,0x4a,0x25}, {0x2e,0x72,0x5c,0x2e}, 
+{0x1c,0x24,0x38,0x1c}, {0xa6,0xf1,0x57,0xa6}, {0xb4,0xc7,0x73,0xb4}, {0xc6,0x51,0x97,0xc6}, 
+{0xe8,0x23,0xcb,0xe8}, {0xdd,0x7c,0xa1,0xdd}, {0x74,0x9c,0xe8,0x74}, {0x1f,0x21,0x3e,0x1f}, 
+{0x4b,0xdd,0x96,0x4b}, {0xbd,0xdc,0x61,0xbd}, {0x8b,0x86,0x0d,0x8b}, {0x8a,0x85,0x0f,0x8a}, 
+{0x70,0x90,0xe0,0x70}, {0x3e,0x42,0x7c,0x3e}, {0xb5,0xc4,0x71,0xb5}, {0x66,0xaa,0xcc,0x66}, 
+{0x48,0xd8,0x90,0x48}, {0x03,0x05,0x06,0x03}, {0xf6,0x01,0xf7,0xf6}, {0x0e,0x12,0x1c,0x0e}, 
+{0x61,0xa3,0xc2,0x61}, {0x35,0x5f,0x6a,0x35}, {0x57,0xf9,0xae,0x57}, {0xb9,0xd0,0x69,0xb9}, 
+{0x86,0x91,0x17,0x86}, {0xc1,0x58,0x99,0xc1}, {0x1d,0x27,0x3a,0x1d}, {0x9e,0xb9,0x27,0x9e}, 
+{0xe1,0x38,0xd9,0xe1}, {0xf8,0x13,0xeb,0xf8}, {0x98,0xb3,0x2b,0x98}, {0x11,0x33,0x22,0x11}, 
+{0x69,0xbb,0xd2,0x69}, {0xd9,0x70,0xa9,0xd9}, {0x8e,0x89,0x07,0x8e}, {0x94,0xa7,0x33,0x94}, 
+{0x9b,0xb6,0x2d,0x9b}, {0x1e,0x22,0x3c,0x1e}, {0x87,0x92,0x15,0x87}, {0xe9,0x20,0xc9,0xe9}, 
+{0xce,0x49,0x87,0xce}, {0x55,0xff,0xaa,0x55}, {0x28,0x78,0x50,0x28}, {0xdf,0x7a,0xa5,0xdf}, 
+{0x8c,0x8f,0x03,0x8c}, {0xa1,0xf8,0x59,0xa1}, {0x89,0x80,0x09,0x89}, {0x0d,0x17,0x1a,0x0d}, 
+{0xbf,0xda,0x65,0xbf}, {0xe6,0x31,0xd7,0xe6}, {0x42,0xc6,0x84,0x42}, {0x68,0xb8,0xd0,0x68}, 
+{0x41,0xc3,0x82,0x41}, {0x99,0xb0,0x29,0x99}, {0x2d,0x77,0x5a,0x2d}, {0x0f,0x11,0x1e,0x0f}, 
+{0xb0,0xcb,0x7b,0xb0}, {0x54,0xfc,0xa8,0x54}, {0xbb,0xd6,0x6d,0xbb}, {0x16,0x3a,0x2c,0x16}
+};
+
+static word8 T4[256][4] = {
+{0x63,0x63,0xa5,0xc6}, {0x7c,0x7c,0x84,0xf8}, {0x77,0x77,0x99,0xee}, {0x7b,0x7b,0x8d,0xf6}, 
+{0xf2,0xf2,0x0d,0xff}, {0x6b,0x6b,0xbd,0xd6}, {0x6f,0x6f,0xb1,0xde}, {0xc5,0xc5,0x54,0x91}, 
+{0x30,0x30,0x50,0x60}, {0x01,0x01,0x03,0x02}, {0x67,0x67,0xa9,0xce}, {0x2b,0x2b,0x7d,0x56}, 
+{0xfe,0xfe,0x19,0xe7}, {0xd7,0xd7,0x62,0xb5}, {0xab,0xab,0xe6,0x4d}, {0x76,0x76,0x9a,0xec}, 
+{0xca,0xca,0x45,0x8f}, {0x82,0x82,0x9d,0x1f}, {0xc9,0xc9,0x40,0x89}, {0x7d,0x7d,0x87,0xfa}, 
+{0xfa,0xfa,0x15,0xef}, {0x59,0x59,0xeb,0xb2}, {0x47,0x47,0xc9,0x8e}, {0xf0,0xf0,0x0b,0xfb}, 
+{0xad,0xad,0xec,0x41}, {0xd4,0xd4,0x67,0xb3}, {0xa2,0xa2,0xfd,0x5f}, {0xaf,0xaf,0xea,0x45}, 
+{0x9c,0x9c,0xbf,0x23}, {0xa4,0xa4,0xf7,0x53}, {0x72,0x72,0x96,0xe4}, {0xc0,0xc0,0x5b,0x9b}, 
+{0xb7,0xb7,0xc2,0x75}, {0xfd,0xfd,0x1c,0xe1}, {0x93,0x93,0xae,0x3d}, {0x26,0x26,0x6a,0x4c}, 
+{0x36,0x36,0x5a,0x6c}, {0x3f,0x3f,0x41,0x7e}, {0xf7,0xf7,0x02,0xf5}, {0xcc,0xcc,0x4f,0x83}, 
+{0x34,0x34,0x5c,0x68}, {0xa5,0xa5,0xf4,0x51}, {0xe5,0xe5,0x34,0xd1}, {0xf1,0xf1,0x08,0xf9}, 
+{0x71,0x71,0x93,0xe2}, {0xd8,0xd8,0x73,0xab}, {0x31,0x31,0x53,0x62}, {0x15,0x15,0x3f,0x2a}, 
+{0x04,0x04,0x0c,0x08}, {0xc7,0xc7,0x52,0x95}, {0x23,0x23,0x65,0x46}, {0xc3,0xc3,0x5e,0x9d}, 
+{0x18,0x18,0x28,0x30}, {0x96,0x96,0xa1,0x37}, {0x05,0x05,0x0f,0x0a}, {0x9a,0x9a,0xb5,0x2f}, 
+{0x07,0x07,0x09,0x0e}, {0x12,0x12,0x36,0x24}, {0x80,0x80,0x9b,0x1b}, {0xe2,0xe2,0x3d,0xdf}, 
+{0xeb,0xeb,0x26,0xcd}, {0x27,0x27,0x69,0x4e}, {0xb2,0xb2,0xcd,0x7f}, {0x75,0x75,0x9f,0xea}, 
+{0x09,0x09,0x1b,0x12}, {0x83,0x83,0x9e,0x1d}, {0x2c,0x2c,0x74,0x58}, {0x1a,0x1a,0x2e,0x34}, 
+{0x1b,0x1b,0x2d,0x36}, {0x6e,0x6e,0xb2,0xdc}, {0x5a,0x5a,0xee,0xb4}, {0xa0,0xa0,0xfb,0x5b}, 
+{0x52,0x52,0xf6,0xa4}, {0x3b,0x3b,0x4d,0x76}, {0xd6,0xd6,0x61,0xb7}, {0xb3,0xb3,0xce,0x7d}, 
+{0x29,0x29,0x7b,0x52}, {0xe3,0xe3,0x3e,0xdd}, {0x2f,0x2f,0x71,0x5e}, {0x84,0x84,0x97,0x13}, 
+{0x53,0x53,0xf5,0xa6}, {0xd1,0xd1,0x68,0xb9}, {0x00,0x00,0x00,0x00}, {0xed,0xed,0x2c,0xc1}, 
+{0x20,0x20,0x60,0x40}, {0xfc,0xfc,0x1f,0xe3}, {0xb1,0xb1,0xc8,0x79}, {0x5b,0x5b,0xed,0xb6}, 
+{0x6a,0x6a,0xbe,0xd4}, {0xcb,0xcb,0x46,0x8d}, {0xbe,0xbe,0xd9,0x67}, {0x39,0x39,0x4b,0x72}, 
+{0x4a,0x4a,0xde,0x94}, {0x4c,0x4c,0xd4,0x98}, {0x58,0x58,0xe8,0xb0}, {0xcf,0xcf,0x4a,0x85}, 
+{0xd0,0xd0,0x6b,0xbb}, {0xef,0xef,0x2a,0xc5}, {0xaa,0xaa,0xe5,0x4f}, {0xfb,0xfb,0x16,0xed}, 
+{0x43,0x43,0xc5,0x86}, {0x4d,0x4d,0xd7,0x9a}, {0x33,0x33,0x55,0x66}, {0x85,0x85,0x94,0x11}, 
+{0x45,0x45,0xcf,0x8a}, {0xf9,0xf9,0x10,0xe9}, {0x02,0x02,0x06,0x04}, {0x7f,0x7f,0x81,0xfe}, 
+{0x50,0x50,0xf0,0xa0}, {0x3c,0x3c,0x44,0x78}, {0x9f,0x9f,0xba,0x25}, {0xa8,0xa8,0xe3,0x4b}, 
+{0x51,0x51,0xf3,0xa2}, {0xa3,0xa3,0xfe,0x5d}, {0x40,0x40,0xc0,0x80}, {0x8f,0x8f,0x8a,0x05}, 
+{0x92,0x92,0xad,0x3f}, {0x9d,0x9d,0xbc,0x21}, {0x38,0x38,0x48,0x70}, {0xf5,0xf5,0x04,0xf1}, 
+{0xbc,0xbc,0xdf,0x63}, {0xb6,0xb6,0xc1,0x77}, {0xda,0xda,0x75,0xaf}, {0x21,0x21,0x63,0x42}, 
+{0x10,0x10,0x30,0x20}, {0xff,0xff,0x1a,0xe5}, {0xf3,0xf3,0x0e,0xfd}, {0xd2,0xd2,0x6d,0xbf}, 
+{0xcd,0xcd,0x4c,0x81}, {0x0c,0x0c,0x14,0x18}, {0x13,0x13,0x35,0x26}, {0xec,0xec,0x2f,0xc3}, 
+{0x5f,0x5f,0xe1,0xbe}, {0x97,0x97,0xa2,0x35}, {0x44,0x44,0xcc,0x88}, {0x17,0x17,0x39,0x2e}, 
+{0xc4,0xc4,0x57,0x93}, {0xa7,0xa7,0xf2,0x55}, {0x7e,0x7e,0x82,0xfc}, {0x3d,0x3d,0x47,0x7a}, 
+{0x64,0x64,0xac,0xc8}, {0x5d,0x5d,0xe7,0xba}, {0x19,0x19,0x2b,0x32}, {0x73,0x73,0x95,0xe6}, 
+{0x60,0x60,0xa0,0xc0}, {0x81,0x81,0x98,0x19}, {0x4f,0x4f,0xd1,0x9e}, {0xdc,0xdc,0x7f,0xa3}, 
+{0x22,0x22,0x66,0x44}, {0x2a,0x2a,0x7e,0x54}, {0x90,0x90,0xab,0x3b}, {0x88,0x88,0x83,0x0b}, 
+{0x46,0x46,0xca,0x8c}, {0xee,0xee,0x29,0xc7}, {0xb8,0xb8,0xd3,0x6b}, {0x14,0x14,0x3c,0x28}, 
+{0xde,0xde,0x79,0xa7}, {0x5e,0x5e,0xe2,0xbc}, {0x0b,0x0b,0x1d,0x16}, {0xdb,0xdb,0x76,0xad}, 
+{0xe0,0xe0,0x3b,0xdb}, {0x32,0x32,0x56,0x64}, {0x3a,0x3a,0x4e,0x74}, {0x0a,0x0a,0x1e,0x14}, 
+{0x49,0x49,0xdb,0x92}, {0x06,0x06,0x0a,0x0c}, {0x24,0x24,0x6c,0x48}, {0x5c,0x5c,0xe4,0xb8}, 
+{0xc2,0xc2,0x5d,0x9f}, {0xd3,0xd3,0x6e,0xbd}, {0xac,0xac,0xef,0x43}, {0x62,0x62,0xa6,0xc4}, 
+{0x91,0x91,0xa8,0x39}, {0x95,0x95,0xa4,0x31}, {0xe4,0xe4,0x37,0xd3}, {0x79,0x79,0x8b,0xf2}, 
+{0xe7,0xe7,0x32,0xd5}, {0xc8,0xc8,0x43,0x8b}, {0x37,0x37,0x59,0x6e}, {0x6d,0x6d,0xb7,0xda}, 
+{0x8d,0x8d,0x8c,0x01}, {0xd5,0xd5,0x64,0xb1}, {0x4e,0x4e,0xd2,0x9c}, {0xa9,0xa9,0xe0,0x49}, 
+{0x6c,0x6c,0xb4,0xd8}, {0x56,0x56,0xfa,0xac}, {0xf4,0xf4,0x07,0xf3}, {0xea,0xea,0x25,0xcf}, 
+{0x65,0x65,0xaf,0xca}, {0x7a,0x7a,0x8e,0xf4}, {0xae,0xae,0xe9,0x47}, {0x08,0x08,0x18,0x10}, 
+{0xba,0xba,0xd5,0x6f}, {0x78,0x78,0x88,0xf0}, {0x25,0x25,0x6f,0x4a}, {0x2e,0x2e,0x72,0x5c}, 
+{0x1c,0x1c,0x24,0x38}, {0xa6,0xa6,0xf1,0x57}, {0xb4,0xb4,0xc7,0x73}, {0xc6,0xc6,0x51,0x97}, 
+{0xe8,0xe8,0x23,0xcb}, {0xdd,0xdd,0x7c,0xa1}, {0x74,0x74,0x9c,0xe8}, {0x1f,0x1f,0x21,0x3e}, 
+{0x4b,0x4b,0xdd,0x96}, {0xbd,0xbd,0xdc,0x61}, {0x8b,0x8b,0x86,0x0d}, {0x8a,0x8a,0x85,0x0f}, 
+{0x70,0x70,0x90,0xe0}, {0x3e,0x3e,0x42,0x7c}, {0xb5,0xb5,0xc4,0x71}, {0x66,0x66,0xaa,0xcc}, 
+{0x48,0x48,0xd8,0x90}, {0x03,0x03,0x05,0x06}, {0xf6,0xf6,0x01,0xf7}, {0x0e,0x0e,0x12,0x1c}, 
+{0x61,0x61,0xa3,0xc2}, {0x35,0x35,0x5f,0x6a}, {0x57,0x57,0xf9,0xae}, {0xb9,0xb9,0xd0,0x69}, 
+{0x86,0x86,0x91,0x17}, {0xc1,0xc1,0x58,0x99}, {0x1d,0x1d,0x27,0x3a}, {0x9e,0x9e,0xb9,0x27}, 
+{0xe1,0xe1,0x38,0xd9}, {0xf8,0xf8,0x13,0xeb}, {0x98,0x98,0xb3,0x2b}, {0x11,0x11,0x33,0x22}, 
+{0x69,0x69,0xbb,0xd2}, {0xd9,0xd9,0x70,0xa9}, {0x8e,0x8e,0x89,0x07}, {0x94,0x94,0xa7,0x33}, 
+{0x9b,0x9b,0xb6,0x2d}, {0x1e,0x1e,0x22,0x3c}, {0x87,0x87,0x92,0x15}, {0xe9,0xe9,0x20,0xc9}, 
+{0xce,0xce,0x49,0x87}, {0x55,0x55,0xff,0xaa}, {0x28,0x28,0x78,0x50}, {0xdf,0xdf,0x7a,0xa5}, 
+{0x8c,0x8c,0x8f,0x03}, {0xa1,0xa1,0xf8,0x59}, {0x89,0x89,0x80,0x09}, {0x0d,0x0d,0x17,0x1a}, 
+{0xbf,0xbf,0xda,0x65}, {0xe6,0xe6,0x31,0xd7}, {0x42,0x42,0xc6,0x84}, {0x68,0x68,0xb8,0xd0}, 
+{0x41,0x41,0xc3,0x82}, {0x99,0x99,0xb0,0x29}, {0x2d,0x2d,0x77,0x5a}, {0x0f,0x0f,0x11,0x1e}, 
+{0xb0,0xb0,0xcb,0x7b}, {0x54,0x54,0xfc,0xa8}, {0xbb,0xbb,0xd6,0x6d}, {0x16,0x16,0x3a,0x2c},
+};
+
+static word8 T5[256][4] = {
+{0x51,0xf4,0xa7,0x50}, {0x7e,0x41,0x65,0x53}, {0x1a,0x17,0xa4,0xc3}, {0x3a,0x27,0x5e,0x96}, 
+{0x3b,0xab,0x6b,0xcb}, {0x1f,0x9d,0x45,0xf1}, {0xac,0xfa,0x58,0xab}, {0x4b,0xe3,0x03,0x93}, 
+{0x20,0x30,0xfa,0x55}, {0xad,0x76,0x6d,0xf6}, {0x88,0xcc,0x76,0x91}, {0xf5,0x02,0x4c,0x25}, 
+{0x4f,0xe5,0xd7,0xfc}, {0xc5,0x2a,0xcb,0xd7}, {0x26,0x35,0x44,0x80}, {0xb5,0x62,0xa3,0x8f}, 
+{0xde,0xb1,0x5a,0x49}, {0x25,0xba,0x1b,0x67}, {0x45,0xea,0x0e,0x98}, {0x5d,0xfe,0xc0,0xe1}, 
+{0xc3,0x2f,0x75,0x02}, {0x81,0x4c,0xf0,0x12}, {0x8d,0x46,0x97,0xa3}, {0x6b,0xd3,0xf9,0xc6}, 
+{0x03,0x8f,0x5f,0xe7}, {0x15,0x92,0x9c,0x95}, {0xbf,0x6d,0x7a,0xeb}, {0x95,0x52,0x59,0xda}, 
+{0xd4,0xbe,0x83,0x2d}, {0x58,0x74,0x21,0xd3}, {0x49,0xe0,0x69,0x29}, {0x8e,0xc9,0xc8,0x44}, 
+{0x75,0xc2,0x89,0x6a}, {0xf4,0x8e,0x79,0x78}, {0x99,0x58,0x3e,0x6b}, {0x27,0xb9,0x71,0xdd}, 
+{0xbe,0xe1,0x4f,0xb6}, {0xf0,0x88,0xad,0x17}, {0xc9,0x20,0xac,0x66}, {0x7d,0xce,0x3a,0xb4}, 
+{0x63,0xdf,0x4a,0x18}, {0xe5,0x1a,0x31,0x82}, {0x97,0x51,0x33,0x60}, {0x62,0x53,0x7f,0x45}, 
+{0xb1,0x64,0x77,0xe0}, {0xbb,0x6b,0xae,0x84}, {0xfe,0x81,0xa0,0x1c}, {0xf9,0x08,0x2b,0x94}, 
+{0x70,0x48,0x68,0x58}, {0x8f,0x45,0xfd,0x19}, {0x94,0xde,0x6c,0x87}, {0x52,0x7b,0xf8,0xb7}, 
+{0xab,0x73,0xd3,0x23}, {0x72,0x4b,0x02,0xe2}, {0xe3,0x1f,0x8f,0x57}, {0x66,0x55,0xab,0x2a}, 
+{0xb2,0xeb,0x28,0x07}, {0x2f,0xb5,0xc2,0x03}, {0x86,0xc5,0x7b,0x9a}, {0xd3,0x37,0x08,0xa5}, 
+{0x30,0x28,0x87,0xf2}, {0x23,0xbf,0xa5,0xb2}, {0x02,0x03,0x6a,0xba}, {0xed,0x16,0x82,0x5c}, 
+{0x8a,0xcf,0x1c,0x2b}, {0xa7,0x79,0xb4,0x92}, {0xf3,0x07,0xf2,0xf0}, {0x4e,0x69,0xe2,0xa1}, 
+{0x65,0xda,0xf4,0xcd}, {0x06,0x05,0xbe,0xd5}, {0xd1,0x34,0x62,0x1f}, {0xc4,0xa6,0xfe,0x8a}, 
+{0x34,0x2e,0x53,0x9d}, {0xa2,0xf3,0x55,0xa0}, {0x05,0x8a,0xe1,0x32}, {0xa4,0xf6,0xeb,0x75}, 
+{0x0b,0x83,0xec,0x39}, {0x40,0x60,0xef,0xaa}, {0x5e,0x71,0x9f,0x06}, {0xbd,0x6e,0x10,0x51}, 
+{0x3e,0x21,0x8a,0xf9}, {0x96,0xdd,0x06,0x3d}, {0xdd,0x3e,0x05,0xae}, {0x4d,0xe6,0xbd,0x46}, 
+{0x91,0x54,0x8d,0xb5}, {0x71,0xc4,0x5d,0x05}, {0x04,0x06,0xd4,0x6f}, {0x60,0x50,0x15,0xff}, 
+{0x19,0x98,0xfb,0x24}, {0xd6,0xbd,0xe9,0x97}, {0x89,0x40,0x43,0xcc}, {0x67,0xd9,0x9e,0x77}, 
+{0xb0,0xe8,0x42,0xbd}, {0x07,0x89,0x8b,0x88}, {0xe7,0x19,0x5b,0x38}, {0x79,0xc8,0xee,0xdb}, 
+{0xa1,0x7c,0x0a,0x47}, {0x7c,0x42,0x0f,0xe9}, {0xf8,0x84,0x1e,0xc9}, {0x00,0x00,0x00,0x00}, 
+{0x09,0x80,0x86,0x83}, {0x32,0x2b,0xed,0x48}, {0x1e,0x11,0x70,0xac}, {0x6c,0x5a,0x72,0x4e}, 
+{0xfd,0x0e,0xff,0xfb}, {0x0f,0x85,0x38,0x56}, {0x3d,0xae,0xd5,0x1e}, {0x36,0x2d,0x39,0x27}, 
+{0x0a,0x0f,0xd9,0x64}, {0x68,0x5c,0xa6,0x21}, {0x9b,0x5b,0x54,0xd1}, {0x24,0x36,0x2e,0x3a}, 
+{0x0c,0x0a,0x67,0xb1}, {0x93,0x57,0xe7,0x0f}, {0xb4,0xee,0x96,0xd2}, {0x1b,0x9b,0x91,0x9e}, 
+{0x80,0xc0,0xc5,0x4f}, {0x61,0xdc,0x20,0xa2}, {0x5a,0x77,0x4b,0x69}, {0x1c,0x12,0x1a,0x16}, 
+{0xe2,0x93,0xba,0x0a}, {0xc0,0xa0,0x2a,0xe5}, {0x3c,0x22,0xe0,0x43}, {0x12,0x1b,0x17,0x1d}, 
+{0x0e,0x09,0x0d,0x0b}, {0xf2,0x8b,0xc7,0xad}, {0x2d,0xb6,0xa8,0xb9}, {0x14,0x1e,0xa9,0xc8}, 
+{0x57,0xf1,0x19,0x85}, {0xaf,0x75,0x07,0x4c}, {0xee,0x99,0xdd,0xbb}, {0xa3,0x7f,0x60,0xfd}, 
+{0xf7,0x01,0x26,0x9f}, {0x5c,0x72,0xf5,0xbc}, {0x44,0x66,0x3b,0xc5}, {0x5b,0xfb,0x7e,0x34}, 
+{0x8b,0x43,0x29,0x76}, {0xcb,0x23,0xc6,0xdc}, {0xb6,0xed,0xfc,0x68}, {0xb8,0xe4,0xf1,0x63}, 
+{0xd7,0x31,0xdc,0xca}, {0x42,0x63,0x85,0x10}, {0x13,0x97,0x22,0x40}, {0x84,0xc6,0x11,0x20}, 
+{0x85,0x4a,0x24,0x7d}, {0xd2,0xbb,0x3d,0xf8}, {0xae,0xf9,0x32,0x11}, {0xc7,0x29,0xa1,0x6d}, 
+{0x1d,0x9e,0x2f,0x4b}, {0xdc,0xb2,0x30,0xf3}, {0x0d,0x86,0x52,0xec}, {0x77,0xc1,0xe3,0xd0}, 
+{0x2b,0xb3,0x16,0x6c}, {0xa9,0x70,0xb9,0x99}, {0x11,0x94,0x48,0xfa}, {0x47,0xe9,0x64,0x22}, 
+{0xa8,0xfc,0x8c,0xc4}, {0xa0,0xf0,0x3f,0x1a}, {0x56,0x7d,0x2c,0xd8}, {0x22,0x33,0x90,0xef}, 
+{0x87,0x49,0x4e,0xc7}, {0xd9,0x38,0xd1,0xc1}, {0x8c,0xca,0xa2,0xfe}, {0x98,0xd4,0x0b,0x36}, 
+{0xa6,0xf5,0x81,0xcf}, {0xa5,0x7a,0xde,0x28}, {0xda,0xb7,0x8e,0x26}, {0x3f,0xad,0xbf,0xa4}, 
+{0x2c,0x3a,0x9d,0xe4}, {0x50,0x78,0x92,0x0d}, {0x6a,0x5f,0xcc,0x9b}, {0x54,0x7e,0x46,0x62}, 
+{0xf6,0x8d,0x13,0xc2}, {0x90,0xd8,0xb8,0xe8}, {0x2e,0x39,0xf7,0x5e}, {0x82,0xc3,0xaf,0xf5}, 
+{0x9f,0x5d,0x80,0xbe}, {0x69,0xd0,0x93,0x7c}, {0x6f,0xd5,0x2d,0xa9}, {0xcf,0x25,0x12,0xb3}, 
+{0xc8,0xac,0x99,0x3b}, {0x10,0x18,0x7d,0xa7}, {0xe8,0x9c,0x63,0x6e}, {0xdb,0x3b,0xbb,0x7b}, 
+{0xcd,0x26,0x78,0x09}, {0x6e,0x59,0x18,0xf4}, {0xec,0x9a,0xb7,0x01}, {0x83,0x4f,0x9a,0xa8}, 
+{0xe6,0x95,0x6e,0x65}, {0xaa,0xff,0xe6,0x7e}, {0x21,0xbc,0xcf,0x08}, {0xef,0x15,0xe8,0xe6}, 
+{0xba,0xe7,0x9b,0xd9}, {0x4a,0x6f,0x36,0xce}, {0xea,0x9f,0x09,0xd4}, {0x29,0xb0,0x7c,0xd6}, 
+{0x31,0xa4,0xb2,0xaf}, {0x2a,0x3f,0x23,0x31}, {0xc6,0xa5,0x94,0x30}, {0x35,0xa2,0x66,0xc0}, 
+{0x74,0x4e,0xbc,0x37}, {0xfc,0x82,0xca,0xa6}, {0xe0,0x90,0xd0,0xb0}, {0x33,0xa7,0xd8,0x15}, 
+{0xf1,0x04,0x98,0x4a}, {0x41,0xec,0xda,0xf7}, {0x7f,0xcd,0x50,0x0e}, {0x17,0x91,0xf6,0x2f}, 
+{0x76,0x4d,0xd6,0x8d}, {0x43,0xef,0xb0,0x4d}, {0xcc,0xaa,0x4d,0x54}, {0xe4,0x96,0x04,0xdf}, 
+{0x9e,0xd1,0xb5,0xe3}, {0x4c,0x6a,0x88,0x1b}, {0xc1,0x2c,0x1f,0xb8}, {0x46,0x65,0x51,0x7f}, 
+{0x9d,0x5e,0xea,0x04}, {0x01,0x8c,0x35,0x5d}, {0xfa,0x87,0x74,0x73}, {0xfb,0x0b,0x41,0x2e}, 
+{0xb3,0x67,0x1d,0x5a}, {0x92,0xdb,0xd2,0x52}, {0xe9,0x10,0x56,0x33}, {0x6d,0xd6,0x47,0x13}, 
+{0x9a,0xd7,0x61,0x8c}, {0x37,0xa1,0x0c,0x7a}, {0x59,0xf8,0x14,0x8e}, {0xeb,0x13,0x3c,0x89}, 
+{0xce,0xa9,0x27,0xee}, {0xb7,0x61,0xc9,0x35}, {0xe1,0x1c,0xe5,0xed}, {0x7a,0x47,0xb1,0x3c}, 
+{0x9c,0xd2,0xdf,0x59}, {0x55,0xf2,0x73,0x3f}, {0x18,0x14,0xce,0x79}, {0x73,0xc7,0x37,0xbf}, 
+{0x53,0xf7,0xcd,0xea}, {0x5f,0xfd,0xaa,0x5b}, {0xdf,0x3d,0x6f,0x14}, {0x78,0x44,0xdb,0x86}, 
+{0xca,0xaf,0xf3,0x81}, {0xb9,0x68,0xc4,0x3e}, {0x38,0x24,0x34,0x2c}, {0xc2,0xa3,0x40,0x5f}, 
+{0x16,0x1d,0xc3,0x72}, {0xbc,0xe2,0x25,0x0c}, {0x28,0x3c,0x49,0x8b}, {0xff,0x0d,0x95,0x41}, 
+{0x39,0xa8,0x01,0x71}, {0x08,0x0c,0xb3,0xde}, {0xd8,0xb4,0xe4,0x9c}, {0x64,0x56,0xc1,0x90}, 
+{0x7b,0xcb,0x84,0x61}, {0xd5,0x32,0xb6,0x70}, {0x48,0x6c,0x5c,0x74}, {0xd0,0xb8,0x57,0x42}
+};
+
+static word8 T6[256][4] = {
+{0x50,0x51,0xf4,0xa7}, {0x53,0x7e,0x41,0x65}, {0xc3,0x1a,0x17,0xa4}, {0x96,0x3a,0x27,0x5e}, 
+{0xcb,0x3b,0xab,0x6b}, {0xf1,0x1f,0x9d,0x45}, {0xab,0xac,0xfa,0x58}, {0x93,0x4b,0xe3,0x03}, 
+{0x55,0x20,0x30,0xfa}, {0xf6,0xad,0x76,0x6d}, {0x91,0x88,0xcc,0x76}, {0x25,0xf5,0x02,0x4c}, 
+{0xfc,0x4f,0xe5,0xd7}, {0xd7,0xc5,0x2a,0xcb}, {0x80,0x26,0x35,0x44}, {0x8f,0xb5,0x62,0xa3}, 
+{0x49,0xde,0xb1,0x5a}, {0x67,0x25,0xba,0x1b}, {0x98,0x45,0xea,0x0e}, {0xe1,0x5d,0xfe,0xc0}, 
+{0x02,0xc3,0x2f,0x75}, {0x12,0x81,0x4c,0xf0}, {0xa3,0x8d,0x46,0x97}, {0xc6,0x6b,0xd3,0xf9}, 
+{0xe7,0x03,0x8f,0x5f}, {0x95,0x15,0x92,0x9c}, {0xeb,0xbf,0x6d,0x7a}, {0xda,0x95,0x52,0x59}, 
+{0x2d,0xd4,0xbe,0x83}, {0xd3,0x58,0x74,0x21}, {0x29,0x49,0xe0,0x69}, {0x44,0x8e,0xc9,0xc8}, 
+{0x6a,0x75,0xc2,0x89}, {0x78,0xf4,0x8e,0x79}, {0x6b,0x99,0x58,0x3e}, {0xdd,0x27,0xb9,0x71}, 
+{0xb6,0xbe,0xe1,0x4f}, {0x17,0xf0,0x88,0xad}, {0x66,0xc9,0x20,0xac}, {0xb4,0x7d,0xce,0x3a}, 
+{0x18,0x63,0xdf,0x4a}, {0x82,0xe5,0x1a,0x31}, {0x60,0x97,0x51,0x33}, {0x45,0x62,0x53,0x7f}, 
+{0xe0,0xb1,0x64,0x77}, {0x84,0xbb,0x6b,0xae}, {0x1c,0xfe,0x81,0xa0}, {0x94,0xf9,0x08,0x2b}, 
+{0x58,0x70,0x48,0x68}, {0x19,0x8f,0x45,0xfd}, {0x87,0x94,0xde,0x6c}, {0xb7,0x52,0x7b,0xf8}, 
+{0x23,0xab,0x73,0xd3}, {0xe2,0x72,0x4b,0x02}, {0x57,0xe3,0x1f,0x8f}, {0x2a,0x66,0x55,0xab}, 
+{0x07,0xb2,0xeb,0x28}, {0x03,0x2f,0xb5,0xc2}, {0x9a,0x86,0xc5,0x7b}, {0xa5,0xd3,0x37,0x08}, 
+{0xf2,0x30,0x28,0x87}, {0xb2,0x23,0xbf,0xa5}, {0xba,0x02,0x03,0x6a}, {0x5c,0xed,0x16,0x82}, 
+{0x2b,0x8a,0xcf,0x1c}, {0x92,0xa7,0x79,0xb4}, {0xf0,0xf3,0x07,0xf2}, {0xa1,0x4e,0x69,0xe2}, 
+{0xcd,0x65,0xda,0xf4}, {0xd5,0x06,0x05,0xbe}, {0x1f,0xd1,0x34,0x62}, {0x8a,0xc4,0xa6,0xfe}, 
+{0x9d,0x34,0x2e,0x53}, {0xa0,0xa2,0xf3,0x55}, {0x32,0x05,0x8a,0xe1}, {0x75,0xa4,0xf6,0xeb}, 
+{0x39,0x0b,0x83,0xec}, {0xaa,0x40,0x60,0xef}, {0x06,0x5e,0x71,0x9f}, {0x51,0xbd,0x6e,0x10}, 
+{0xf9,0x3e,0x21,0x8a}, {0x3d,0x96,0xdd,0x06}, {0xae,0xdd,0x3e,0x05}, {0x46,0x4d,0xe6,0xbd}, 
+{0xb5,0x91,0x54,0x8d}, {0x05,0x71,0xc4,0x5d}, {0x6f,0x04,0x06,0xd4}, {0xff,0x60,0x50,0x15}, 
+{0x24,0x19,0x98,0xfb}, {0x97,0xd6,0xbd,0xe9}, {0xcc,0x89,0x40,0x43}, {0x77,0x67,0xd9,0x9e}, 
+{0xbd,0xb0,0xe8,0x42}, {0x88,0x07,0x89,0x8b}, {0x38,0xe7,0x19,0x5b}, {0xdb,0x79,0xc8,0xee}, 
+{0x47,0xa1,0x7c,0x0a}, {0xe9,0x7c,0x42,0x0f}, {0xc9,0xf8,0x84,0x1e}, {0x00,0x00,0x00,0x00}, 
+{0x83,0x09,0x80,0x86}, {0x48,0x32,0x2b,0xed}, {0xac,0x1e,0x11,0x70}, {0x4e,0x6c,0x5a,0x72}, 
+{0xfb,0xfd,0x0e,0xff}, {0x56,0x0f,0x85,0x38}, {0x1e,0x3d,0xae,0xd5}, {0x27,0x36,0x2d,0x39}, 
+{0x64,0x0a,0x0f,0xd9}, {0x21,0x68,0x5c,0xa6}, {0xd1,0x9b,0x5b,0x54}, {0x3a,0x24,0x36,0x2e}, 
+{0xb1,0x0c,0x0a,0x67}, {0x0f,0x93,0x57,0xe7}, {0xd2,0xb4,0xee,0x96}, {0x9e,0x1b,0x9b,0x91}, 
+{0x4f,0x80,0xc0,0xc5}, {0xa2,0x61,0xdc,0x20}, {0x69,0x5a,0x77,0x4b}, {0x16,0x1c,0x12,0x1a}, 
+{0x0a,0xe2,0x93,0xba}, {0xe5,0xc0,0xa0,0x2a}, {0x43,0x3c,0x22,0xe0}, {0x1d,0x12,0x1b,0x17}, 
+{0x0b,0x0e,0x09,0x0d}, {0xad,0xf2,0x8b,0xc7}, {0xb9,0x2d,0xb6,0xa8}, {0xc8,0x14,0x1e,0xa9}, 
+{0x85,0x57,0xf1,0x19}, {0x4c,0xaf,0x75,0x07}, {0xbb,0xee,0x99,0xdd}, {0xfd,0xa3,0x7f,0x60}, 
+{0x9f,0xf7,0x01,0x26}, {0xbc,0x5c,0x72,0xf5}, {0xc5,0x44,0x66,0x3b}, {0x34,0x5b,0xfb,0x7e}, 
+{0x76,0x8b,0x43,0x29}, {0xdc,0xcb,0x23,0xc6}, {0x68,0xb6,0xed,0xfc}, {0x63,0xb8,0xe4,0xf1}, 
+{0xca,0xd7,0x31,0xdc}, {0x10,0x42,0x63,0x85}, {0x40,0x13,0x97,0x22}, {0x20,0x84,0xc6,0x11}, 
+{0x7d,0x85,0x4a,0x24}, {0xf8,0xd2,0xbb,0x3d}, {0x11,0xae,0xf9,0x32}, {0x6d,0xc7,0x29,0xa1}, 
+{0x4b,0x1d,0x9e,0x2f}, {0xf3,0xdc,0xb2,0x30}, {0xec,0x0d,0x86,0x52}, {0xd0,0x77,0xc1,0xe3}, 
+{0x6c,0x2b,0xb3,0x16}, {0x99,0xa9,0x70,0xb9}, {0xfa,0x11,0x94,0x48}, {0x22,0x47,0xe9,0x64}, 
+{0xc4,0xa8,0xfc,0x8c}, {0x1a,0xa0,0xf0,0x3f}, {0xd8,0x56,0x7d,0x2c}, {0xef,0x22,0x33,0x90}, 
+{0xc7,0x87,0x49,0x4e}, {0xc1,0xd9,0x38,0xd1}, {0xfe,0x8c,0xca,0xa2}, {0x36,0x98,0xd4,0x0b}, 
+{0xcf,0xa6,0xf5,0x81}, {0x28,0xa5,0x7a,0xde}, {0x26,0xda,0xb7,0x8e}, {0xa4,0x3f,0xad,0xbf}, 
+{0xe4,0x2c,0x3a,0x9d}, {0x0d,0x50,0x78,0x92}, {0x9b,0x6a,0x5f,0xcc}, {0x62,0x54,0x7e,0x46}, 
+{0xc2,0xf6,0x8d,0x13}, {0xe8,0x90,0xd8,0xb8}, {0x5e,0x2e,0x39,0xf7}, {0xf5,0x82,0xc3,0xaf}, 
+{0xbe,0x9f,0x5d,0x80}, {0x7c,0x69,0xd0,0x93}, {0xa9,0x6f,0xd5,0x2d}, {0xb3,0xcf,0x25,0x12}, 
+{0x3b,0xc8,0xac,0x99}, {0xa7,0x10,0x18,0x7d}, {0x6e,0xe8,0x9c,0x63}, {0x7b,0xdb,0x3b,0xbb}, 
+{0x09,0xcd,0x26,0x78}, {0xf4,0x6e,0x59,0x18}, {0x01,0xec,0x9a,0xb7}, {0xa8,0x83,0x4f,0x9a}, 
+{0x65,0xe6,0x95,0x6e}, {0x7e,0xaa,0xff,0xe6}, {0x08,0x21,0xbc,0xcf}, {0xe6,0xef,0x15,0xe8}, 
+{0xd9,0xba,0xe7,0x9b}, {0xce,0x4a,0x6f,0x36}, {0xd4,0xea,0x9f,0x09}, {0xd6,0x29,0xb0,0x7c}, 
+{0xaf,0x31,0xa4,0xb2}, {0x31,0x2a,0x3f,0x23}, {0x30,0xc6,0xa5,0x94}, {0xc0,0x35,0xa2,0x66}, 
+{0x37,0x74,0x4e,0xbc}, {0xa6,0xfc,0x82,0xca}, {0xb0,0xe0,0x90,0xd0}, {0x15,0x33,0xa7,0xd8}, 
+{0x4a,0xf1,0x04,0x98}, {0xf7,0x41,0xec,0xda}, {0x0e,0x7f,0xcd,0x50}, {0x2f,0x17,0x91,0xf6}, 
+{0x8d,0x76,0x4d,0xd6}, {0x4d,0x43,0xef,0xb0}, {0x54,0xcc,0xaa,0x4d}, {0xdf,0xe4,0x96,0x04}, 
+{0xe3,0x9e,0xd1,0xb5}, {0x1b,0x4c,0x6a,0x88}, {0xb8,0xc1,0x2c,0x1f}, {0x7f,0x46,0x65,0x51}, 
+{0x04,0x9d,0x5e,0xea}, {0x5d,0x01,0x8c,0x35}, {0x73,0xfa,0x87,0x74}, {0x2e,0xfb,0x0b,0x41}, 
+{0x5a,0xb3,0x67,0x1d}, {0x52,0x92,0xdb,0xd2}, {0x33,0xe9,0x10,0x56}, {0x13,0x6d,0xd6,0x47}, 
+{0x8c,0x9a,0xd7,0x61}, {0x7a,0x37,0xa1,0x0c}, {0x8e,0x59,0xf8,0x14}, {0x89,0xeb,0x13,0x3c}, 
+{0xee,0xce,0xa9,0x27}, {0x35,0xb7,0x61,0xc9}, {0xed,0xe1,0x1c,0xe5}, {0x3c,0x7a,0x47,0xb1}, 
+{0x59,0x9c,0xd2,0xdf}, {0x3f,0x55,0xf2,0x73}, {0x79,0x18,0x14,0xce}, {0xbf,0x73,0xc7,0x37}, 
+{0xea,0x53,0xf7,0xcd}, {0x5b,0x5f,0xfd,0xaa}, {0x14,0xdf,0x3d,0x6f}, {0x86,0x78,0x44,0xdb}, 
+{0x81,0xca,0xaf,0xf3}, {0x3e,0xb9,0x68,0xc4}, {0x2c,0x38,0x24,0x34}, {0x5f,0xc2,0xa3,0x40}, 
+{0x72,0x16,0x1d,0xc3}, {0x0c,0xbc,0xe2,0x25}, {0x8b,0x28,0x3c,0x49}, {0x41,0xff,0x0d,0x95}, 
+{0x71,0x39,0xa8,0x01}, {0xde,0x08,0x0c,0xb3}, {0x9c,0xd8,0xb4,0xe4}, {0x90,0x64,0x56,0xc1}, 
+{0x61,0x7b,0xcb,0x84}, {0x70,0xd5,0x32,0xb6}, {0x74,0x48,0x6c,0x5c}, {0x42,0xd0,0xb8,0x57},
+};
+
+static word8 T7[256][4] = {
+{0xa7,0x50,0x51,0xf4}, {0x65,0x53,0x7e,0x41}, {0xa4,0xc3,0x1a,0x17}, {0x5e,0x96,0x3a,0x27}, 
+{0x6b,0xcb,0x3b,0xab}, {0x45,0xf1,0x1f,0x9d}, {0x58,0xab,0xac,0xfa}, {0x03,0x93,0x4b,0xe3}, 
+{0xfa,0x55,0x20,0x30}, {0x6d,0xf6,0xad,0x76}, {0x76,0x91,0x88,0xcc}, {0x4c,0x25,0xf5,0x02}, 
+{0xd7,0xfc,0x4f,0xe5}, {0xcb,0xd7,0xc5,0x2a}, {0x44,0x80,0x26,0x35}, {0xa3,0x8f,0xb5,0x62}, 
+{0x5a,0x49,0xde,0xb1}, {0x1b,0x67,0x25,0xba}, {0x0e,0x98,0x45,0xea}, {0xc0,0xe1,0x5d,0xfe}, 
+{0x75,0x02,0xc3,0x2f}, {0xf0,0x12,0x81,0x4c}, {0x97,0xa3,0x8d,0x46}, {0xf9,0xc6,0x6b,0xd3}, 
+{0x5f,0xe7,0x03,0x8f}, {0x9c,0x95,0x15,0x92}, {0x7a,0xeb,0xbf,0x6d}, {0x59,0xda,0x95,0x52}, 
+{0x83,0x2d,0xd4,0xbe}, {0x21,0xd3,0x58,0x74}, {0x69,0x29,0x49,0xe0}, {0xc8,0x44,0x8e,0xc9}, 
+{0x89,0x6a,0x75,0xc2}, {0x79,0x78,0xf4,0x8e}, {0x3e,0x6b,0x99,0x58}, {0x71,0xdd,0x27,0xb9}, 
+{0x4f,0xb6,0xbe,0xe1}, {0xad,0x17,0xf0,0x88}, {0xac,0x66,0xc9,0x20}, {0x3a,0xb4,0x7d,0xce}, 
+{0x4a,0x18,0x63,0xdf}, {0x31,0x82,0xe5,0x1a}, {0x33,0x60,0x97,0x51}, {0x7f,0x45,0x62,0x53}, 
+{0x77,0xe0,0xb1,0x64}, {0xae,0x84,0xbb,0x6b}, {0xa0,0x1c,0xfe,0x81}, {0x2b,0x94,0xf9,0x08}, 
+{0x68,0x58,0x70,0x48}, {0xfd,0x19,0x8f,0x45}, {0x6c,0x87,0x94,0xde}, {0xf8,0xb7,0x52,0x7b}, 
+{0xd3,0x23,0xab,0x73}, {0x02,0xe2,0x72,0x4b}, {0x8f,0x57,0xe3,0x1f}, {0xab,0x2a,0x66,0x55}, 
+{0x28,0x07,0xb2,0xeb}, {0xc2,0x03,0x2f,0xb5}, {0x7b,0x9a,0x86,0xc5}, {0x08,0xa5,0xd3,0x37}, 
+{0x87,0xf2,0x30,0x28}, {0xa5,0xb2,0x23,0xbf}, {0x6a,0xba,0x02,0x03}, {0x82,0x5c,0xed,0x16}, 
+{0x1c,0x2b,0x8a,0xcf}, {0xb4,0x92,0xa7,0x79}, {0xf2,0xf0,0xf3,0x07}, {0xe2,0xa1,0x4e,0x69}, 
+{0xf4,0xcd,0x65,0xda}, {0xbe,0xd5,0x06,0x05}, {0x62,0x1f,0xd1,0x34}, {0xfe,0x8a,0xc4,0xa6}, 
+{0x53,0x9d,0x34,0x2e}, {0x55,0xa0,0xa2,0xf3}, {0xe1,0x32,0x05,0x8a}, {0xeb,0x75,0xa4,0xf6}, 
+{0xec,0x39,0x0b,0x83}, {0xef,0xaa,0x40,0x60}, {0x9f,0x06,0x5e,0x71}, {0x10,0x51,0xbd,0x6e}, 
+{0x8a,0xf9,0x3e,0x21}, {0x06,0x3d,0x96,0xdd}, {0x05,0xae,0xdd,0x3e}, {0xbd,0x46,0x4d,0xe6}, 
+{0x8d,0xb5,0x91,0x54}, {0x5d,0x05,0x71,0xc4}, {0xd4,0x6f,0x04,0x06}, {0x15,0xff,0x60,0x50}, 
+{0xfb,0x24,0x19,0x98}, {0xe9,0x97,0xd6,0xbd}, {0x43,0xcc,0x89,0x40}, {0x9e,0x77,0x67,0xd9}, 
+{0x42,0xbd,0xb0,0xe8}, {0x8b,0x88,0x07,0x89}, {0x5b,0x38,0xe7,0x19}, {0xee,0xdb,0x79,0xc8}, 
+{0x0a,0x47,0xa1,0x7c}, {0x0f,0xe9,0x7c,0x42}, {0x1e,0xc9,0xf8,0x84}, {0x00,0x00,0x00,0x00}, 
+{0x86,0x83,0x09,0x80}, {0xed,0x48,0x32,0x2b}, {0x70,0xac,0x1e,0x11}, {0x72,0x4e,0x6c,0x5a}, 
+{0xff,0xfb,0xfd,0x0e}, {0x38,0x56,0x0f,0x85}, {0xd5,0x1e,0x3d,0xae}, {0x39,0x27,0x36,0x2d}, 
+{0xd9,0x64,0x0a,0x0f}, {0xa6,0x21,0x68,0x5c}, {0x54,0xd1,0x9b,0x5b}, {0x2e,0x3a,0x24,0x36}, 
+{0x67,0xb1,0x0c,0x0a}, {0xe7,0x0f,0x93,0x57}, {0x96,0xd2,0xb4,0xee}, {0x91,0x9e,0x1b,0x9b}, 
+{0xc5,0x4f,0x80,0xc0}, {0x20,0xa2,0x61,0xdc}, {0x4b,0x69,0x5a,0x77}, {0x1a,0x16,0x1c,0x12}, 
+{0xba,0x0a,0xe2,0x93}, {0x2a,0xe5,0xc0,0xa0}, {0xe0,0x43,0x3c,0x22}, {0x17,0x1d,0x12,0x1b}, 
+{0x0d,0x0b,0x0e,0x09}, {0xc7,0xad,0xf2,0x8b}, {0xa8,0xb9,0x2d,0xb6}, {0xa9,0xc8,0x14,0x1e}, 
+{0x19,0x85,0x57,0xf1}, {0x07,0x4c,0xaf,0x75}, {0xdd,0xbb,0xee,0x99}, {0x60,0xfd,0xa3,0x7f}, 
+{0x26,0x9f,0xf7,0x01}, {0xf5,0xbc,0x5c,0x72}, {0x3b,0xc5,0x44,0x66}, {0x7e,0x34,0x5b,0xfb}, 
+{0x29,0x76,0x8b,0x43}, {0xc6,0xdc,0xcb,0x23}, {0xfc,0x68,0xb6,0xed}, {0xf1,0x63,0xb8,0xe4}, 
+{0xdc,0xca,0xd7,0x31}, {0x85,0x10,0x42,0x63}, {0x22,0x40,0x13,0x97}, {0x11,0x20,0x84,0xc6}, 
+{0x24,0x7d,0x85,0x4a}, {0x3d,0xf8,0xd2,0xbb}, {0x32,0x11,0xae,0xf9}, {0xa1,0x6d,0xc7,0x29}, 
+{0x2f,0x4b,0x1d,0x9e}, {0x30,0xf3,0xdc,0xb2}, {0x52,0xec,0x0d,0x86}, {0xe3,0xd0,0x77,0xc1}, 
+{0x16,0x6c,0x2b,0xb3}, {0xb9,0x99,0xa9,0x70}, {0x48,0xfa,0x11,0x94}, {0x64,0x22,0x47,0xe9}, 
+{0x8c,0xc4,0xa8,0xfc}, {0x3f,0x1a,0xa0,0xf0}, {0x2c,0xd8,0x56,0x7d}, {0x90,0xef,0x22,0x33}, 
+{0x4e,0xc7,0x87,0x49}, {0xd1,0xc1,0xd9,0x38}, {0xa2,0xfe,0x8c,0xca}, {0x0b,0x36,0x98,0xd4}, 
+{0x81,0xcf,0xa6,0xf5}, {0xde,0x28,0xa5,0x7a}, {0x8e,0x26,0xda,0xb7}, {0xbf,0xa4,0x3f,0xad}, 
+{0x9d,0xe4,0x2c,0x3a}, {0x92,0x0d,0x50,0x78}, {0xcc,0x9b,0x6a,0x5f}, {0x46,0x62,0x54,0x7e}, 
+{0x13,0xc2,0xf6,0x8d}, {0xb8,0xe8,0x90,0xd8}, {0xf7,0x5e,0x2e,0x39}, {0xaf,0xf5,0x82,0xc3}, 
+{0x80,0xbe,0x9f,0x5d}, {0x93,0x7c,0x69,0xd0}, {0x2d,0xa9,0x6f,0xd5}, {0x12,0xb3,0xcf,0x25}, 
+{0x99,0x3b,0xc8,0xac}, {0x7d,0xa7,0x10,0x18}, {0x63,0x6e,0xe8,0x9c}, {0xbb,0x7b,0xdb,0x3b}, 
+{0x78,0x09,0xcd,0x26}, {0x18,0xf4,0x6e,0x59}, {0xb7,0x01,0xec,0x9a}, {0x9a,0xa8,0x83,0x4f}, 
+{0x6e,0x65,0xe6,0x95}, {0xe6,0x7e,0xaa,0xff}, {0xcf,0x08,0x21,0xbc}, {0xe8,0xe6,0xef,0x15}, 
+{0x9b,0xd9,0xba,0xe7}, {0x36,0xce,0x4a,0x6f}, {0x09,0xd4,0xea,0x9f}, {0x7c,0xd6,0x29,0xb0}, 
+{0xb2,0xaf,0x31,0xa4}, {0x23,0x31,0x2a,0x3f}, {0x94,0x30,0xc6,0xa5}, {0x66,0xc0,0x35,0xa2}, 
+{0xbc,0x37,0x74,0x4e}, {0xca,0xa6,0xfc,0x82}, {0xd0,0xb0,0xe0,0x90}, {0xd8,0x15,0x33,0xa7}, 
+{0x98,0x4a,0xf1,0x04}, {0xda,0xf7,0x41,0xec}, {0x50,0x0e,0x7f,0xcd}, {0xf6,0x2f,0x17,0x91}, 
+{0xd6,0x8d,0x76,0x4d}, {0xb0,0x4d,0x43,0xef}, {0x4d,0x54,0xcc,0xaa}, {0x04,0xdf,0xe4,0x96}, 
+{0xb5,0xe3,0x9e,0xd1}, {0x88,0x1b,0x4c,0x6a}, {0x1f,0xb8,0xc1,0x2c}, {0x51,0x7f,0x46,0x65}, 
+{0xea,0x04,0x9d,0x5e}, {0x35,0x5d,0x01,0x8c}, {0x74,0x73,0xfa,0x87}, {0x41,0x2e,0xfb,0x0b}, 
+{0x1d,0x5a,0xb3,0x67}, {0xd2,0x52,0x92,0xdb}, {0x56,0x33,0xe9,0x10}, {0x47,0x13,0x6d,0xd6}, 
+{0x61,0x8c,0x9a,0xd7}, {0x0c,0x7a,0x37,0xa1}, {0x14,0x8e,0x59,0xf8}, {0x3c,0x89,0xeb,0x13}, 
+{0x27,0xee,0xce,0xa9}, {0xc9,0x35,0xb7,0x61}, {0xe5,0xed,0xe1,0x1c}, {0xb1,0x3c,0x7a,0x47}, 
+{0xdf,0x59,0x9c,0xd2}, {0x73,0x3f,0x55,0xf2}, {0xce,0x79,0x18,0x14}, {0x37,0xbf,0x73,0xc7}, 
+{0xcd,0xea,0x53,0xf7}, {0xaa,0x5b,0x5f,0xfd}, {0x6f,0x14,0xdf,0x3d}, {0xdb,0x86,0x78,0x44}, 
+{0xf3,0x81,0xca,0xaf}, {0xc4,0x3e,0xb9,0x68}, {0x34,0x2c,0x38,0x24}, {0x40,0x5f,0xc2,0xa3}, 
+{0xc3,0x72,0x16,0x1d}, {0x25,0x0c,0xbc,0xe2}, {0x49,0x8b,0x28,0x3c}, {0x95,0x41,0xff,0x0d}, 
+{0x01,0x71,0x39,0xa8}, {0xb3,0xde,0x08,0x0c}, {0xe4,0x9c,0xd8,0xb4}, {0xc1,0x90,0x64,0x56}, 
+{0x84,0x61,0x7b,0xcb}, {0xb6,0x70,0xd5,0x32}, {0x5c,0x74,0x48,0x6c}, {0x57,0x42,0xd0,0xb8},
+};
+
+static word8 T8[256][4] = {
+{0xf4,0xa7,0x50,0x51}, {0x41,0x65,0x53,0x7e}, {0x17,0xa4,0xc3,0x1a}, {0x27,0x5e,0x96,0x3a}, 
+{0xab,0x6b,0xcb,0x3b}, {0x9d,0x45,0xf1,0x1f}, {0xfa,0x58,0xab,0xac}, {0xe3,0x03,0x93,0x4b}, 
+{0x30,0xfa,0x55,0x20}, {0x76,0x6d,0xf6,0xad}, {0xcc,0x76,0x91,0x88}, {0x02,0x4c,0x25,0xf5}, 
+{0xe5,0xd7,0xfc,0x4f}, {0x2a,0xcb,0xd7,0xc5}, {0x35,0x44,0x80,0x26}, {0x62,0xa3,0x8f,0xb5}, 
+{0xb1,0x5a,0x49,0xde}, {0xba,0x1b,0x67,0x25}, {0xea,0x0e,0x98,0x45}, {0xfe,0xc0,0xe1,0x5d}, 
+{0x2f,0x75,0x02,0xc3}, {0x4c,0xf0,0x12,0x81}, {0x46,0x97,0xa3,0x8d}, {0xd3,0xf9,0xc6,0x6b}, 
+{0x8f,0x5f,0xe7,0x03}, {0x92,0x9c,0x95,0x15}, {0x6d,0x7a,0xeb,0xbf}, {0x52,0x59,0xda,0x95}, 
+{0xbe,0x83,0x2d,0xd4}, {0x74,0x21,0xd3,0x58}, {0xe0,0x69,0x29,0x49}, {0xc9,0xc8,0x44,0x8e}, 
+{0xc2,0x89,0x6a,0x75}, {0x8e,0x79,0x78,0xf4}, {0x58,0x3e,0x6b,0x99}, {0xb9,0x71,0xdd,0x27}, 
+{0xe1,0x4f,0xb6,0xbe}, {0x88,0xad,0x17,0xf0}, {0x20,0xac,0x66,0xc9}, {0xce,0x3a,0xb4,0x7d}, 
+{0xdf,0x4a,0x18,0x63}, {0x1a,0x31,0x82,0xe5}, {0x51,0x33,0x60,0x97}, {0x53,0x7f,0x45,0x62}, 
+{0x64,0x77,0xe0,0xb1}, {0x6b,0xae,0x84,0xbb}, {0x81,0xa0,0x1c,0xfe}, {0x08,0x2b,0x94,0xf9}, 
+{0x48,0x68,0x58,0x70}, {0x45,0xfd,0x19,0x8f}, {0xde,0x6c,0x87,0x94}, {0x7b,0xf8,0xb7,0x52}, 
+{0x73,0xd3,0x23,0xab}, {0x4b,0x02,0xe2,0x72}, {0x1f,0x8f,0x57,0xe3}, {0x55,0xab,0x2a,0x66}, 
+{0xeb,0x28,0x07,0xb2}, {0xb5,0xc2,0x03,0x2f}, {0xc5,0x7b,0x9a,0x86}, {0x37,0x08,0xa5,0xd3}, 
+{0x28,0x87,0xf2,0x30}, {0xbf,0xa5,0xb2,0x23}, {0x03,0x6a,0xba,0x02}, {0x16,0x82,0x5c,0xed}, 
+{0xcf,0x1c,0x2b,0x8a}, {0x79,0xb4,0x92,0xa7}, {0x07,0xf2,0xf0,0xf3}, {0x69,0xe2,0xa1,0x4e}, 
+{0xda,0xf4,0xcd,0x65}, {0x05,0xbe,0xd5,0x06}, {0x34,0x62,0x1f,0xd1}, {0xa6,0xfe,0x8a,0xc4}, 
+{0x2e,0x53,0x9d,0x34}, {0xf3,0x55,0xa0,0xa2}, {0x8a,0xe1,0x32,0x05}, {0xf6,0xeb,0x75,0xa4}, 
+{0x83,0xec,0x39,0x0b}, {0x60,0xef,0xaa,0x40}, {0x71,0x9f,0x06,0x5e}, {0x6e,0x10,0x51,0xbd}, 
+{0x21,0x8a,0xf9,0x3e}, {0xdd,0x06,0x3d,0x96}, {0x3e,0x05,0xae,0xdd}, {0xe6,0xbd,0x46,0x4d}, 
+{0x54,0x8d,0xb5,0x91}, {0xc4,0x5d,0x05,0x71}, {0x06,0xd4,0x6f,0x04}, {0x50,0x15,0xff,0x60}, 
+{0x98,0xfb,0x24,0x19}, {0xbd,0xe9,0x97,0xd6}, {0x40,0x43,0xcc,0x89}, {0xd9,0x9e,0x77,0x67}, 
+{0xe8,0x42,0xbd,0xb0}, {0x89,0x8b,0x88,0x07}, {0x19,0x5b,0x38,0xe7}, {0xc8,0xee,0xdb,0x79}, 
+{0x7c,0x0a,0x47,0xa1}, {0x42,0x0f,0xe9,0x7c}, {0x84,0x1e,0xc9,0xf8}, {0x00,0x00,0x00,0x00}, 
+{0x80,0x86,0x83,0x09}, {0x2b,0xed,0x48,0x32}, {0x11,0x70,0xac,0x1e}, {0x5a,0x72,0x4e,0x6c}, 
+{0x0e,0xff,0xfb,0xfd}, {0x85,0x38,0x56,0x0f}, {0xae,0xd5,0x1e,0x3d}, {0x2d,0x39,0x27,0x36}, 
+{0x0f,0xd9,0x64,0x0a}, {0x5c,0xa6,0x21,0x68}, {0x5b,0x54,0xd1,0x9b}, {0x36,0x2e,0x3a,0x24}, 
+{0x0a,0x67,0xb1,0x0c}, {0x57,0xe7,0x0f,0x93}, {0xee,0x96,0xd2,0xb4}, {0x9b,0x91,0x9e,0x1b}, 
+{0xc0,0xc5,0x4f,0x80}, {0xdc,0x20,0xa2,0x61}, {0x77,0x4b,0x69,0x5a}, {0x12,0x1a,0x16,0x1c}, 
+{0x93,0xba,0x0a,0xe2}, {0xa0,0x2a,0xe5,0xc0}, {0x22,0xe0,0x43,0x3c}, {0x1b,0x17,0x1d,0x12}, 
+{0x09,0x0d,0x0b,0x0e}, {0x8b,0xc7,0xad,0xf2}, {0xb6,0xa8,0xb9,0x2d}, {0x1e,0xa9,0xc8,0x14}, 
+{0xf1,0x19,0x85,0x57}, {0x75,0x07,0x4c,0xaf}, {0x99,0xdd,0xbb,0xee}, {0x7f,0x60,0xfd,0xa3}, 
+{0x01,0x26,0x9f,0xf7}, {0x72,0xf5,0xbc,0x5c}, {0x66,0x3b,0xc5,0x44}, {0xfb,0x7e,0x34,0x5b}, 
+{0x43,0x29,0x76,0x8b}, {0x23,0xc6,0xdc,0xcb}, {0xed,0xfc,0x68,0xb6}, {0xe4,0xf1,0x63,0xb8}, 
+{0x31,0xdc,0xca,0xd7}, {0x63,0x85,0x10,0x42}, {0x97,0x22,0x40,0x13}, {0xc6,0x11,0x20,0x84}, 
+{0x4a,0x24,0x7d,0x85}, {0xbb,0x3d,0xf8,0xd2}, {0xf9,0x32,0x11,0xae}, {0x29,0xa1,0x6d,0xc7}, 
+{0x9e,0x2f,0x4b,0x1d}, {0xb2,0x30,0xf3,0xdc}, {0x86,0x52,0xec,0x0d}, {0xc1,0xe3,0xd0,0x77}, 
+{0xb3,0x16,0x6c,0x2b}, {0x70,0xb9,0x99,0xa9}, {0x94,0x48,0xfa,0x11}, {0xe9,0x64,0x22,0x47}, 
+{0xfc,0x8c,0xc4,0xa8}, {0xf0,0x3f,0x1a,0xa0}, {0x7d,0x2c,0xd8,0x56}, {0x33,0x90,0xef,0x22}, 
+{0x49,0x4e,0xc7,0x87}, {0x38,0xd1,0xc1,0xd9}, {0xca,0xa2,0xfe,0x8c}, {0xd4,0x0b,0x36,0x98}, 
+{0xf5,0x81,0xcf,0xa6}, {0x7a,0xde,0x28,0xa5}, {0xb7,0x8e,0x26,0xda}, {0xad,0xbf,0xa4,0x3f}, 
+{0x3a,0x9d,0xe4,0x2c}, {0x78,0x92,0x0d,0x50}, {0x5f,0xcc,0x9b,0x6a}, {0x7e,0x46,0x62,0x54}, 
+{0x8d,0x13,0xc2,0xf6}, {0xd8,0xb8,0xe8,0x90}, {0x39,0xf7,0x5e,0x2e}, {0xc3,0xaf,0xf5,0x82}, 
+{0x5d,0x80,0xbe,0x9f}, {0xd0,0x93,0x7c,0x69}, {0xd5,0x2d,0xa9,0x6f}, {0x25,0x12,0xb3,0xcf}, 
+{0xac,0x99,0x3b,0xc8}, {0x18,0x7d,0xa7,0x10}, {0x9c,0x63,0x6e,0xe8}, {0x3b,0xbb,0x7b,0xdb}, 
+{0x26,0x78,0x09,0xcd}, {0x59,0x18,0xf4,0x6e}, {0x9a,0xb7,0x01,0xec}, {0x4f,0x9a,0xa8,0x83}, 
+{0x95,0x6e,0x65,0xe6}, {0xff,0xe6,0x7e,0xaa}, {0xbc,0xcf,0x08,0x21}, {0x15,0xe8,0xe6,0xef}, 
+{0xe7,0x9b,0xd9,0xba}, {0x6f,0x36,0xce,0x4a}, {0x9f,0x09,0xd4,0xea}, {0xb0,0x7c,0xd6,0x29}, 
+{0xa4,0xb2,0xaf,0x31}, {0x3f,0x23,0x31,0x2a}, {0xa5,0x94,0x30,0xc6}, {0xa2,0x66,0xc0,0x35}, 
+{0x4e,0xbc,0x37,0x74}, {0x82,0xca,0xa6,0xfc}, {0x90,0xd0,0xb0,0xe0}, {0xa7,0xd8,0x15,0x33}, 
+{0x04,0x98,0x4a,0xf1}, {0xec,0xda,0xf7,0x41}, {0xcd,0x50,0x0e,0x7f}, {0x91,0xf6,0x2f,0x17}, 
+{0x4d,0xd6,0x8d,0x76}, {0xef,0xb0,0x4d,0x43}, {0xaa,0x4d,0x54,0xcc}, {0x96,0x04,0xdf,0xe4}, 
+{0xd1,0xb5,0xe3,0x9e}, {0x6a,0x88,0x1b,0x4c}, {0x2c,0x1f,0xb8,0xc1}, {0x65,0x51,0x7f,0x46}, 
+{0x5e,0xea,0x04,0x9d}, {0x8c,0x35,0x5d,0x01}, {0x87,0x74,0x73,0xfa}, {0x0b,0x41,0x2e,0xfb}, 
+{0x67,0x1d,0x5a,0xb3}, {0xdb,0xd2,0x52,0x92}, {0x10,0x56,0x33,0xe9}, {0xd6,0x47,0x13,0x6d}, 
+{0xd7,0x61,0x8c,0x9a}, {0xa1,0x0c,0x7a,0x37}, {0xf8,0x14,0x8e,0x59}, {0x13,0x3c,0x89,0xeb}, 
+{0xa9,0x27,0xee,0xce}, {0x61,0xc9,0x35,0xb7}, {0x1c,0xe5,0xed,0xe1}, {0x47,0xb1,0x3c,0x7a}, 
+{0xd2,0xdf,0x59,0x9c}, {0xf2,0x73,0x3f,0x55}, {0x14,0xce,0x79,0x18}, {0xc7,0x37,0xbf,0x73}, 
+{0xf7,0xcd,0xea,0x53}, {0xfd,0xaa,0x5b,0x5f}, {0x3d,0x6f,0x14,0xdf}, {0x44,0xdb,0x86,0x78}, 
+{0xaf,0xf3,0x81,0xca}, {0x68,0xc4,0x3e,0xb9}, {0x24,0x34,0x2c,0x38}, {0xa3,0x40,0x5f,0xc2}, 
+{0x1d,0xc3,0x72,0x16}, {0xe2,0x25,0x0c,0xbc}, {0x3c,0x49,0x8b,0x28}, {0x0d,0x95,0x41,0xff}, 
+{0xa8,0x01,0x71,0x39}, {0x0c,0xb3,0xde,0x08}, {0xb4,0xe4,0x9c,0xd8}, {0x56,0xc1,0x90,0x64}, 
+{0xcb,0x84,0x61,0x7b}, {0x32,0xb6,0x70,0xd5}, {0x6c,0x5c,0x74,0x48}, {0xb8,0x57,0x42,0xd0},
+};
+
+static word8 S5[256] = {
+0x52,0x09,0x6a,0xd5,
+0x30,0x36,0xa5,0x38,
+0xbf,0x40,0xa3,0x9e,
+0x81,0xf3,0xd7,0xfb,
+0x7c,0xe3,0x39,0x82,
+0x9b,0x2f,0xff,0x87,
+0x34,0x8e,0x43,0x44,
+0xc4,0xde,0xe9,0xcb,
+0x54,0x7b,0x94,0x32,
+0xa6,0xc2,0x23,0x3d,
+0xee,0x4c,0x95,0x0b,
+0x42,0xfa,0xc3,0x4e,
+0x08,0x2e,0xa1,0x66,
+0x28,0xd9,0x24,0xb2,
+0x76,0x5b,0xa2,0x49,
+0x6d,0x8b,0xd1,0x25,
+0x72,0xf8,0xf6,0x64,
+0x86,0x68,0x98,0x16,
+0xd4,0xa4,0x5c,0xcc,
+0x5d,0x65,0xb6,0x92,
+0x6c,0x70,0x48,0x50,
+0xfd,0xed,0xb9,0xda,
+0x5e,0x15,0x46,0x57,
+0xa7,0x8d,0x9d,0x84,
+0x90,0xd8,0xab,0x00,
+0x8c,0xbc,0xd3,0x0a,
+0xf7,0xe4,0x58,0x05,
+0xb8,0xb3,0x45,0x06,
+0xd0,0x2c,0x1e,0x8f,
+0xca,0x3f,0x0f,0x02,
+0xc1,0xaf,0xbd,0x03,
+0x01,0x13,0x8a,0x6b,
+0x3a,0x91,0x11,0x41,
+0x4f,0x67,0xdc,0xea,
+0x97,0xf2,0xcf,0xce,
+0xf0,0xb4,0xe6,0x73,
+0x96,0xac,0x74,0x22,
+0xe7,0xad,0x35,0x85,
+0xe2,0xf9,0x37,0xe8,
+0x1c,0x75,0xdf,0x6e,
+0x47,0xf1,0x1a,0x71,
+0x1d,0x29,0xc5,0x89,
+0x6f,0xb7,0x62,0x0e,
+0xaa,0x18,0xbe,0x1b,
+0xfc,0x56,0x3e,0x4b,
+0xc6,0xd2,0x79,0x20,
+0x9a,0xdb,0xc0,0xfe,
+0x78,0xcd,0x5a,0xf4,
+0x1f,0xdd,0xa8,0x33,
+0x88,0x07,0xc7,0x31,
+0xb1,0x12,0x10,0x59,
+0x27,0x80,0xec,0x5f,
+0x60,0x51,0x7f,0xa9,
+0x19,0xb5,0x4a,0x0d,
+0x2d,0xe5,0x7a,0x9f,
+0x93,0xc9,0x9c,0xef,
+0xa0,0xe0,0x3b,0x4d,
+0xae,0x2a,0xf5,0xb0,
+0xc8,0xeb,0xbb,0x3c,
+0x83,0x53,0x99,0x61,
+0x17,0x2b,0x04,0x7e,
+0xba,0x77,0xd6,0x26,
+0xe1,0x69,0x14,0x63,
+0x55,0x21,0x0c,0x7d
+};
+
+static word8 U1[256][4] = {
+{0x00,0x00,0x00,0x00}, {0x0e,0x09,0x0d,0x0b}, {0x1c,0x12,0x1a,0x16}, {0x12,0x1b,0x17,0x1d}, 
+{0x38,0x24,0x34,0x2c}, {0x36,0x2d,0x39,0x27}, {0x24,0x36,0x2e,0x3a}, {0x2a,0x3f,0x23,0x31}, 
+{0x70,0x48,0x68,0x58}, {0x7e,0x41,0x65,0x53}, {0x6c,0x5a,0x72,0x4e}, {0x62,0x53,0x7f,0x45}, 
+{0x48,0x6c,0x5c,0x74}, {0x46,0x65,0x51,0x7f}, {0x54,0x7e,0x46,0x62}, {0x5a,0x77,0x4b,0x69}, 
+{0xe0,0x90,0xd0,0xb0}, {0xee,0x99,0xdd,0xbb}, {0xfc,0x82,0xca,0xa6}, {0xf2,0x8b,0xc7,0xad}, 
+{0xd8,0xb4,0xe4,0x9c}, {0xd6,0xbd,0xe9,0x97}, {0xc4,0xa6,0xfe,0x8a}, {0xca,0xaf,0xf3,0x81}, 
+{0x90,0xd8,0xb8,0xe8}, {0x9e,0xd1,0xb5,0xe3}, {0x8c,0xca,0xa2,0xfe}, {0x82,0xc3,0xaf,0xf5}, 
+{0xa8,0xfc,0x8c,0xc4}, {0xa6,0xf5,0x81,0xcf}, {0xb4,0xee,0x96,0xd2}, {0xba,0xe7,0x9b,0xd9}, 
+{0xdb,0x3b,0xbb,0x7b}, {0xd5,0x32,0xb6,0x70}, {0xc7,0x29,0xa1,0x6d}, {0xc9,0x20,0xac,0x66}, 
+{0xe3,0x1f,0x8f,0x57}, {0xed,0x16,0x82,0x5c}, {0xff,0x0d,0x95,0x41}, {0xf1,0x04,0x98,0x4a}, 
+{0xab,0x73,0xd3,0x23}, {0xa5,0x7a,0xde,0x28}, {0xb7,0x61,0xc9,0x35}, {0xb9,0x68,0xc4,0x3e}, 
+{0x93,0x57,0xe7,0x0f}, {0x9d,0x5e,0xea,0x04}, {0x8f,0x45,0xfd,0x19}, {0x81,0x4c,0xf0,0x12}, 
+{0x3b,0xab,0x6b,0xcb}, {0x35,0xa2,0x66,0xc0}, {0x27,0xb9,0x71,0xdd}, {0x29,0xb0,0x7c,0xd6}, 
+{0x03,0x8f,0x5f,0xe7}, {0x0d,0x86,0x52,0xec}, {0x1f,0x9d,0x45,0xf1}, {0x11,0x94,0x48,0xfa}, 
+{0x4b,0xe3,0x03,0x93}, {0x45,0xea,0x0e,0x98}, {0x57,0xf1,0x19,0x85}, {0x59,0xf8,0x14,0x8e}, 
+{0x73,0xc7,0x37,0xbf}, {0x7d,0xce,0x3a,0xb4}, {0x6f,0xd5,0x2d,0xa9}, {0x61,0xdc,0x20,0xa2}, 
+{0xad,0x76,0x6d,0xf6}, {0xa3,0x7f,0x60,0xfd}, {0xb1,0x64,0x77,0xe0}, {0xbf,0x6d,0x7a,0xeb}, 
+{0x95,0x52,0x59,0xda}, {0x9b,0x5b,0x54,0xd1}, {0x89,0x40,0x43,0xcc}, {0x87,0x49,0x4e,0xc7}, 
+{0xdd,0x3e,0x05,0xae}, {0xd3,0x37,0x08,0xa5}, {0xc1,0x2c,0x1f,0xb8}, {0xcf,0x25,0x12,0xb3}, 
+{0xe5,0x1a,0x31,0x82}, {0xeb,0x13,0x3c,0x89}, {0xf9,0x08,0x2b,0x94}, {0xf7,0x01,0x26,0x9f}, 
+{0x4d,0xe6,0xbd,0x46}, {0x43,0xef,0xb0,0x4d}, {0x51,0xf4,0xa7,0x50}, {0x5f,0xfd,0xaa,0x5b}, 
+{0x75,0xc2,0x89,0x6a}, {0x7b,0xcb,0x84,0x61}, {0x69,0xd0,0x93,0x7c}, {0x67,0xd9,0x9e,0x77}, 
+{0x3d,0xae,0xd5,0x1e}, {0x33,0xa7,0xd8,0x15}, {0x21,0xbc,0xcf,0x08}, {0x2f,0xb5,0xc2,0x03}, 
+{0x05,0x8a,0xe1,0x32}, {0x0b,0x83,0xec,0x39}, {0x19,0x98,0xfb,0x24}, {0x17,0x91,0xf6,0x2f}, 
+{0x76,0x4d,0xd6,0x8d}, {0x78,0x44,0xdb,0x86}, {0x6a,0x5f,0xcc,0x9b}, {0x64,0x56,0xc1,0x90}, 
+{0x4e,0x69,0xe2,0xa1}, {0x40,0x60,0xef,0xaa}, {0x52,0x7b,0xf8,0xb7}, {0x5c,0x72,0xf5,0xbc}, 
+{0x06,0x05,0xbe,0xd5}, {0x08,0x0c,0xb3,0xde}, {0x1a,0x17,0xa4,0xc3}, {0x14,0x1e,0xa9,0xc8}, 
+{0x3e,0x21,0x8a,0xf9}, {0x30,0x28,0x87,0xf2}, {0x22,0x33,0x90,0xef}, {0x2c,0x3a,0x9d,0xe4}, 
+{0x96,0xdd,0x06,0x3d}, {0x98,0xd4,0x0b,0x36}, {0x8a,0xcf,0x1c,0x2b}, {0x84,0xc6,0x11,0x20}, 
+{0xae,0xf9,0x32,0x11}, {0xa0,0xf0,0x3f,0x1a}, {0xb2,0xeb,0x28,0x07}, {0xbc,0xe2,0x25,0x0c}, 
+{0xe6,0x95,0x6e,0x65}, {0xe8,0x9c,0x63,0x6e}, {0xfa,0x87,0x74,0x73}, {0xf4,0x8e,0x79,0x78}, 
+{0xde,0xb1,0x5a,0x49}, {0xd0,0xb8,0x57,0x42}, {0xc2,0xa3,0x40,0x5f}, {0xcc,0xaa,0x4d,0x54}, 
+{0x41,0xec,0xda,0xf7}, {0x4f,0xe5,0xd7,0xfc}, {0x5d,0xfe,0xc0,0xe1}, {0x53,0xf7,0xcd,0xea}, 
+{0x79,0xc8,0xee,0xdb}, {0x77,0xc1,0xe3,0xd0}, {0x65,0xda,0xf4,0xcd}, {0x6b,0xd3,0xf9,0xc6}, 
+{0x31,0xa4,0xb2,0xaf}, {0x3f,0xad,0xbf,0xa4}, {0x2d,0xb6,0xa8,0xb9}, {0x23,0xbf,0xa5,0xb2}, 
+{0x09,0x80,0x86,0x83}, {0x07,0x89,0x8b,0x88}, {0x15,0x92,0x9c,0x95}, {0x1b,0x9b,0x91,0x9e}, 
+{0xa1,0x7c,0x0a,0x47}, {0xaf,0x75,0x07,0x4c}, {0xbd,0x6e,0x10,0x51}, {0xb3,0x67,0x1d,0x5a}, 
+{0x99,0x58,0x3e,0x6b}, {0x97,0x51,0x33,0x60}, {0x85,0x4a,0x24,0x7d}, {0x8b,0x43,0x29,0x76}, 
+{0xd1,0x34,0x62,0x1f}, {0xdf,0x3d,0x6f,0x14}, {0xcd,0x26,0x78,0x09}, {0xc3,0x2f,0x75,0x02}, 
+{0xe9,0x10,0x56,0x33}, {0xe7,0x19,0x5b,0x38}, {0xf5,0x02,0x4c,0x25}, {0xfb,0x0b,0x41,0x2e}, 
+{0x9a,0xd7,0x61,0x8c}, {0x94,0xde,0x6c,0x87}, {0x86,0xc5,0x7b,0x9a}, {0x88,0xcc,0x76,0x91}, 
+{0xa2,0xf3,0x55,0xa0}, {0xac,0xfa,0x58,0xab}, {0xbe,0xe1,0x4f,0xb6}, {0xb0,0xe8,0x42,0xbd}, 
+{0xea,0x9f,0x09,0xd4}, {0xe4,0x96,0x04,0xdf}, {0xf6,0x8d,0x13,0xc2}, {0xf8,0x84,0x1e,0xc9}, 
+{0xd2,0xbb,0x3d,0xf8}, {0xdc,0xb2,0x30,0xf3}, {0xce,0xa9,0x27,0xee}, {0xc0,0xa0,0x2a,0xe5}, 
+{0x7a,0x47,0xb1,0x3c}, {0x74,0x4e,0xbc,0x37}, {0x66,0x55,0xab,0x2a}, {0x68,0x5c,0xa6,0x21}, 
+{0x42,0x63,0x85,0x10}, {0x4c,0x6a,0x88,0x1b}, {0x5e,0x71,0x9f,0x06}, {0x50,0x78,0x92,0x0d}, 
+{0x0a,0x0f,0xd9,0x64}, {0x04,0x06,0xd4,0x6f}, {0x16,0x1d,0xc3,0x72}, {0x18,0x14,0xce,0x79}, 
+{0x32,0x2b,0xed,0x48}, {0x3c,0x22,0xe0,0x43}, {0x2e,0x39,0xf7,0x5e}, {0x20,0x30,0xfa,0x55}, 
+{0xec,0x9a,0xb7,0x01}, {0xe2,0x93,0xba,0x0a}, {0xf0,0x88,0xad,0x17}, {0xfe,0x81,0xa0,0x1c}, 
+{0xd4,0xbe,0x83,0x2d}, {0xda,0xb7,0x8e,0x26}, {0xc8,0xac,0x99,0x3b}, {0xc6,0xa5,0x94,0x30}, 
+{0x9c,0xd2,0xdf,0x59}, {0x92,0xdb,0xd2,0x52}, {0x80,0xc0,0xc5,0x4f}, {0x8e,0xc9,0xc8,0x44}, 
+{0xa4,0xf6,0xeb,0x75}, {0xaa,0xff,0xe6,0x7e}, {0xb8,0xe4,0xf1,0x63}, {0xb6,0xed,0xfc,0x68}, 
+{0x0c,0x0a,0x67,0xb1}, {0x02,0x03,0x6a,0xba}, {0x10,0x18,0x7d,0xa7}, {0x1e,0x11,0x70,0xac}, 
+{0x34,0x2e,0x53,0x9d}, {0x3a,0x27,0x5e,0x96}, {0x28,0x3c,0x49,0x8b}, {0x26,0x35,0x44,0x80}, 
+{0x7c,0x42,0x0f,0xe9}, {0x72,0x4b,0x02,0xe2}, {0x60,0x50,0x15,0xff}, {0x6e,0x59,0x18,0xf4}, 
+{0x44,0x66,0x3b,0xc5}, {0x4a,0x6f,0x36,0xce}, {0x58,0x74,0x21,0xd3}, {0x56,0x7d,0x2c,0xd8}, 
+{0x37,0xa1,0x0c,0x7a}, {0x39,0xa8,0x01,0x71}, {0x2b,0xb3,0x16,0x6c}, {0x25,0xba,0x1b,0x67}, 
+{0x0f,0x85,0x38,0x56}, {0x01,0x8c,0x35,0x5d}, {0x13,0x97,0x22,0x40}, {0x1d,0x9e,0x2f,0x4b}, 
+{0x47,0xe9,0x64,0x22}, {0x49,0xe0,0x69,0x29}, {0x5b,0xfb,0x7e,0x34}, {0x55,0xf2,0x73,0x3f}, 
+{0x7f,0xcd,0x50,0x0e}, {0x71,0xc4,0x5d,0x05}, {0x63,0xdf,0x4a,0x18}, {0x6d,0xd6,0x47,0x13}, 
+{0xd7,0x31,0xdc,0xca}, {0xd9,0x38,0xd1,0xc1}, {0xcb,0x23,0xc6,0xdc}, {0xc5,0x2a,0xcb,0xd7}, 
+{0xef,0x15,0xe8,0xe6}, {0xe1,0x1c,0xe5,0xed}, {0xf3,0x07,0xf2,0xf0}, {0xfd,0x0e,0xff,0xfb}, 
+{0xa7,0x79,0xb4,0x92}, {0xa9,0x70,0xb9,0x99}, {0xbb,0x6b,0xae,0x84}, {0xb5,0x62,0xa3,0x8f}, 
+{0x9f,0x5d,0x80,0xbe}, {0x91,0x54,0x8d,0xb5}, {0x83,0x4f,0x9a,0xa8}, {0x8d,0x46,0x97,0xa3}
+};
+
+static word8 U2[256][4] = {
+{0x00,0x00,0x00,0x00}, {0x0b,0x0e,0x09,0x0d}, {0x16,0x1c,0x12,0x1a}, {0x1d,0x12,0x1b,0x17}, 
+{0x2c,0x38,0x24,0x34}, {0x27,0x36,0x2d,0x39}, {0x3a,0x24,0x36,0x2e}, {0x31,0x2a,0x3f,0x23}, 
+{0x58,0x70,0x48,0x68}, {0x53,0x7e,0x41,0x65}, {0x4e,0x6c,0x5a,0x72}, {0x45,0x62,0x53,0x7f}, 
+{0x74,0x48,0x6c,0x5c}, {0x7f,0x46,0x65,0x51}, {0x62,0x54,0x7e,0x46}, {0x69,0x5a,0x77,0x4b}, 
+{0xb0,0xe0,0x90,0xd0}, {0xbb,0xee,0x99,0xdd}, {0xa6,0xfc,0x82,0xca}, {0xad,0xf2,0x8b,0xc7}, 
+{0x9c,0xd8,0xb4,0xe4}, {0x97,0xd6,0xbd,0xe9}, {0x8a,0xc4,0xa6,0xfe}, {0x81,0xca,0xaf,0xf3}, 
+{0xe8,0x90,0xd8,0xb8}, {0xe3,0x9e,0xd1,0xb5}, {0xfe,0x8c,0xca,0xa2}, {0xf5,0x82,0xc3,0xaf}, 
+{0xc4,0xa8,0xfc,0x8c}, {0xcf,0xa6,0xf5,0x81}, {0xd2,0xb4,0xee,0x96}, {0xd9,0xba,0xe7,0x9b}, 
+{0x7b,0xdb,0x3b,0xbb}, {0x70,0xd5,0x32,0xb6}, {0x6d,0xc7,0x29,0xa1}, {0x66,0xc9,0x20,0xac}, 
+{0x57,0xe3,0x1f,0x8f}, {0x5c,0xed,0x16,0x82}, {0x41,0xff,0x0d,0x95}, {0x4a,0xf1,0x04,0x98}, 
+{0x23,0xab,0x73,0xd3}, {0x28,0xa5,0x7a,0xde}, {0x35,0xb7,0x61,0xc9}, {0x3e,0xb9,0x68,0xc4}, 
+{0x0f,0x93,0x57,0xe7}, {0x04,0x9d,0x5e,0xea}, {0x19,0x8f,0x45,0xfd}, {0x12,0x81,0x4c,0xf0}, 
+{0xcb,0x3b,0xab,0x6b}, {0xc0,0x35,0xa2,0x66}, {0xdd,0x27,0xb9,0x71}, {0xd6,0x29,0xb0,0x7c}, 
+{0xe7,0x03,0x8f,0x5f}, {0xec,0x0d,0x86,0x52}, {0xf1,0x1f,0x9d,0x45}, {0xfa,0x11,0x94,0x48}, 
+{0x93,0x4b,0xe3,0x03}, {0x98,0x45,0xea,0x0e}, {0x85,0x57,0xf1,0x19}, {0x8e,0x59,0xf8,0x14}, 
+{0xbf,0x73,0xc7,0x37}, {0xb4,0x7d,0xce,0x3a}, {0xa9,0x6f,0xd5,0x2d}, {0xa2,0x61,0xdc,0x20}, 
+{0xf6,0xad,0x76,0x6d}, {0xfd,0xa3,0x7f,0x60}, {0xe0,0xb1,0x64,0x77}, {0xeb,0xbf,0x6d,0x7a}, 
+{0xda,0x95,0x52,0x59}, {0xd1,0x9b,0x5b,0x54}, {0xcc,0x89,0x40,0x43}, {0xc7,0x87,0x49,0x4e}, 
+{0xae,0xdd,0x3e,0x05}, {0xa5,0xd3,0x37,0x08}, {0xb8,0xc1,0x2c,0x1f}, {0xb3,0xcf,0x25,0x12}, 
+{0x82,0xe5,0x1a,0x31}, {0x89,0xeb,0x13,0x3c}, {0x94,0xf9,0x08,0x2b}, {0x9f,0xf7,0x01,0x26}, 
+{0x46,0x4d,0xe6,0xbd}, {0x4d,0x43,0xef,0xb0}, {0x50,0x51,0xf4,0xa7}, {0x5b,0x5f,0xfd,0xaa}, 
+{0x6a,0x75,0xc2,0x89}, {0x61,0x7b,0xcb,0x84}, {0x7c,0x69,0xd0,0x93}, {0x77,0x67,0xd9,0x9e}, 
+{0x1e,0x3d,0xae,0xd5}, {0x15,0x33,0xa7,0xd8}, {0x08,0x21,0xbc,0xcf}, {0x03,0x2f,0xb5,0xc2}, 
+{0x32,0x05,0x8a,0xe1}, {0x39,0x0b,0x83,0xec}, {0x24,0x19,0x98,0xfb}, {0x2f,0x17,0x91,0xf6}, 
+{0x8d,0x76,0x4d,0xd6}, {0x86,0x78,0x44,0xdb}, {0x9b,0x6a,0x5f,0xcc}, {0x90,0x64,0x56,0xc1}, 
+{0xa1,0x4e,0x69,0xe2}, {0xaa,0x40,0x60,0xef}, {0xb7,0x52,0x7b,0xf8}, {0xbc,0x5c,0x72,0xf5}, 
+{0xd5,0x06,0x05,0xbe}, {0xde,0x08,0x0c,0xb3}, {0xc3,0x1a,0x17,0xa4}, {0xc8,0x14,0x1e,0xa9}, 
+{0xf9,0x3e,0x21,0x8a}, {0xf2,0x30,0x28,0x87}, {0xef,0x22,0x33,0x90}, {0xe4,0x2c,0x3a,0x9d}, 
+{0x3d,0x96,0xdd,0x06}, {0x36,0x98,0xd4,0x0b}, {0x2b,0x8a,0xcf,0x1c}, {0x20,0x84,0xc6,0x11}, 
+{0x11,0xae,0xf9,0x32}, {0x1a,0xa0,0xf0,0x3f}, {0x07,0xb2,0xeb,0x28}, {0x0c,0xbc,0xe2,0x25}, 
+{0x65,0xe6,0x95,0x6e}, {0x6e,0xe8,0x9c,0x63}, {0x73,0xfa,0x87,0x74}, {0x78,0xf4,0x8e,0x79}, 
+{0x49,0xde,0xb1,0x5a}, {0x42,0xd0,0xb8,0x57}, {0x5f,0xc2,0xa3,0x40}, {0x54,0xcc,0xaa,0x4d}, 
+{0xf7,0x41,0xec,0xda}, {0xfc,0x4f,0xe5,0xd7}, {0xe1,0x5d,0xfe,0xc0}, {0xea,0x53,0xf7,0xcd}, 
+{0xdb,0x79,0xc8,0xee}, {0xd0,0x77,0xc1,0xe3}, {0xcd,0x65,0xda,0xf4}, {0xc6,0x6b,0xd3,0xf9}, 
+{0xaf,0x31,0xa4,0xb2}, {0xa4,0x3f,0xad,0xbf}, {0xb9,0x2d,0xb6,0xa8}, {0xb2,0x23,0xbf,0xa5}, 
+{0x83,0x09,0x80,0x86}, {0x88,0x07,0x89,0x8b}, {0x95,0x15,0x92,0x9c}, {0x9e,0x1b,0x9b,0x91}, 
+{0x47,0xa1,0x7c,0x0a}, {0x4c,0xaf,0x75,0x07}, {0x51,0xbd,0x6e,0x10}, {0x5a,0xb3,0x67,0x1d}, 
+{0x6b,0x99,0x58,0x3e}, {0x60,0x97,0x51,0x33}, {0x7d,0x85,0x4a,0x24}, {0x76,0x8b,0x43,0x29}, 
+{0x1f,0xd1,0x34,0x62}, {0x14,0xdf,0x3d,0x6f}, {0x09,0xcd,0x26,0x78}, {0x02,0xc3,0x2f,0x75}, 
+{0x33,0xe9,0x10,0x56}, {0x38,0xe7,0x19,0x5b}, {0x25,0xf5,0x02,0x4c}, {0x2e,0xfb,0x0b,0x41}, 
+{0x8c,0x9a,0xd7,0x61}, {0x87,0x94,0xde,0x6c}, {0x9a,0x86,0xc5,0x7b}, {0x91,0x88,0xcc,0x76}, 
+{0xa0,0xa2,0xf3,0x55}, {0xab,0xac,0xfa,0x58}, {0xb6,0xbe,0xe1,0x4f}, {0xbd,0xb0,0xe8,0x42}, 
+{0xd4,0xea,0x9f,0x09}, {0xdf,0xe4,0x96,0x04}, {0xc2,0xf6,0x8d,0x13}, {0xc9,0xf8,0x84,0x1e}, 
+{0xf8,0xd2,0xbb,0x3d}, {0xf3,0xdc,0xb2,0x30}, {0xee,0xce,0xa9,0x27}, {0xe5,0xc0,0xa0,0x2a}, 
+{0x3c,0x7a,0x47,0xb1}, {0x37,0x74,0x4e,0xbc}, {0x2a,0x66,0x55,0xab}, {0x21,0x68,0x5c,0xa6}, 
+{0x10,0x42,0x63,0x85}, {0x1b,0x4c,0x6a,0x88}, {0x06,0x5e,0x71,0x9f}, {0x0d,0x50,0x78,0x92}, 
+{0x64,0x0a,0x0f,0xd9}, {0x6f,0x04,0x06,0xd4}, {0x72,0x16,0x1d,0xc3}, {0x79,0x18,0x14,0xce}, 
+{0x48,0x32,0x2b,0xed}, {0x43,0x3c,0x22,0xe0}, {0x5e,0x2e,0x39,0xf7}, {0x55,0x20,0x30,0xfa}, 
+{0x01,0xec,0x9a,0xb7}, {0x0a,0xe2,0x93,0xba}, {0x17,0xf0,0x88,0xad}, {0x1c,0xfe,0x81,0xa0}, 
+{0x2d,0xd4,0xbe,0x83}, {0x26,0xda,0xb7,0x8e}, {0x3b,0xc8,0xac,0x99}, {0x30,0xc6,0xa5,0x94}, 
+{0x59,0x9c,0xd2,0xdf}, {0x52,0x92,0xdb,0xd2}, {0x4f,0x80,0xc0,0xc5}, {0x44,0x8e,0xc9,0xc8}, 
+{0x75,0xa4,0xf6,0xeb}, {0x7e,0xaa,0xff,0xe6}, {0x63,0xb8,0xe4,0xf1}, {0x68,0xb6,0xed,0xfc}, 
+{0xb1,0x0c,0x0a,0x67}, {0xba,0x02,0x03,0x6a}, {0xa7,0x10,0x18,0x7d}, {0xac,0x1e,0x11,0x70}, 
+{0x9d,0x34,0x2e,0x53}, {0x96,0x3a,0x27,0x5e}, {0x8b,0x28,0x3c,0x49}, {0x80,0x26,0x35,0x44}, 
+{0xe9,0x7c,0x42,0x0f}, {0xe2,0x72,0x4b,0x02}, {0xff,0x60,0x50,0x15}, {0xf4,0x6e,0x59,0x18}, 
+{0xc5,0x44,0x66,0x3b}, {0xce,0x4a,0x6f,0x36}, {0xd3,0x58,0x74,0x21}, {0xd8,0x56,0x7d,0x2c}, 
+{0x7a,0x37,0xa1,0x0c}, {0x71,0x39,0xa8,0x01}, {0x6c,0x2b,0xb3,0x16}, {0x67,0x25,0xba,0x1b}, 
+{0x56,0x0f,0x85,0x38}, {0x5d,0x01,0x8c,0x35}, {0x40,0x13,0x97,0x22}, {0x4b,0x1d,0x9e,0x2f}, 
+{0x22,0x47,0xe9,0x64}, {0x29,0x49,0xe0,0x69}, {0x34,0x5b,0xfb,0x7e}, {0x3f,0x55,0xf2,0x73}, 
+{0x0e,0x7f,0xcd,0x50}, {0x05,0x71,0xc4,0x5d}, {0x18,0x63,0xdf,0x4a}, {0x13,0x6d,0xd6,0x47}, 
+{0xca,0xd7,0x31,0xdc}, {0xc1,0xd9,0x38,0xd1}, {0xdc,0xcb,0x23,0xc6}, {0xd7,0xc5,0x2a,0xcb}, 
+{0xe6,0xef,0x15,0xe8}, {0xed,0xe1,0x1c,0xe5}, {0xf0,0xf3,0x07,0xf2}, {0xfb,0xfd,0x0e,0xff}, 
+{0x92,0xa7,0x79,0xb4}, {0x99,0xa9,0x70,0xb9}, {0x84,0xbb,0x6b,0xae}, {0x8f,0xb5,0x62,0xa3}, 
+{0xbe,0x9f,0x5d,0x80}, {0xb5,0x91,0x54,0x8d}, {0xa8,0x83,0x4f,0x9a}, {0xa3,0x8d,0x46,0x97}
+};
+
+static word8 U3[256][4] = {
+{0x00,0x00,0x00,0x00}, {0x0d,0x0b,0x0e,0x09}, {0x1a,0x16,0x1c,0x12}, {0x17,0x1d,0x12,0x1b}, 
+{0x34,0x2c,0x38,0x24}, {0x39,0x27,0x36,0x2d}, {0x2e,0x3a,0x24,0x36}, {0x23,0x31,0x2a,0x3f}, 
+{0x68,0x58,0x70,0x48}, {0x65,0x53,0x7e,0x41}, {0x72,0x4e,0x6c,0x5a}, {0x7f,0x45,0x62,0x53}, 
+{0x5c,0x74,0x48,0x6c}, {0x51,0x7f,0x46,0x65}, {0x46,0x62,0x54,0x7e}, {0x4b,0x69,0x5a,0x77}, 
+{0xd0,0xb0,0xe0,0x90}, {0xdd,0xbb,0xee,0x99}, {0xca,0xa6,0xfc,0x82}, {0xc7,0xad,0xf2,0x8b}, 
+{0xe4,0x9c,0xd8,0xb4}, {0xe9,0x97,0xd6,0xbd}, {0xfe,0x8a,0xc4,0xa6}, {0xf3,0x81,0xca,0xaf}, 
+{0xb8,0xe8,0x90,0xd8}, {0xb5,0xe3,0x9e,0xd1}, {0xa2,0xfe,0x8c,0xca}, {0xaf,0xf5,0x82,0xc3}, 
+{0x8c,0xc4,0xa8,0xfc}, {0x81,0xcf,0xa6,0xf5}, {0x96,0xd2,0xb4,0xee}, {0x9b,0xd9,0xba,0xe7}, 
+{0xbb,0x7b,0xdb,0x3b}, {0xb6,0x70,0xd5,0x32}, {0xa1,0x6d,0xc7,0x29}, {0xac,0x66,0xc9,0x20}, 
+{0x8f,0x57,0xe3,0x1f}, {0x82,0x5c,0xed,0x16}, {0x95,0x41,0xff,0x0d}, {0x98,0x4a,0xf1,0x04}, 
+{0xd3,0x23,0xab,0x73}, {0xde,0x28,0xa5,0x7a}, {0xc9,0x35,0xb7,0x61}, {0xc4,0x3e,0xb9,0x68}, 
+{0xe7,0x0f,0x93,0x57}, {0xea,0x04,0x9d,0x5e}, {0xfd,0x19,0x8f,0x45}, {0xf0,0x12,0x81,0x4c}, 
+{0x6b,0xcb,0x3b,0xab}, {0x66,0xc0,0x35,0xa2}, {0x71,0xdd,0x27,0xb9}, {0x7c,0xd6,0x29,0xb0}, 
+{0x5f,0xe7,0x03,0x8f}, {0x52,0xec,0x0d,0x86}, {0x45,0xf1,0x1f,0x9d}, {0x48,0xfa,0x11,0x94}, 
+{0x03,0x93,0x4b,0xe3}, {0x0e,0x98,0x45,0xea}, {0x19,0x85,0x57,0xf1}, {0x14,0x8e,0x59,0xf8}, 
+{0x37,0xbf,0x73,0xc7}, {0x3a,0xb4,0x7d,0xce}, {0x2d,0xa9,0x6f,0xd5}, {0x20,0xa2,0x61,0xdc}, 
+{0x6d,0xf6,0xad,0x76}, {0x60,0xfd,0xa3,0x7f}, {0x77,0xe0,0xb1,0x64}, {0x7a,0xeb,0xbf,0x6d}, 
+{0x59,0xda,0x95,0x52}, {0x54,0xd1,0x9b,0x5b}, {0x43,0xcc,0x89,0x40}, {0x4e,0xc7,0x87,0x49}, 
+{0x05,0xae,0xdd,0x3e}, {0x08,0xa5,0xd3,0x37}, {0x1f,0xb8,0xc1,0x2c}, {0x12,0xb3,0xcf,0x25}, 
+{0x31,0x82,0xe5,0x1a}, {0x3c,0x89,0xeb,0x13}, {0x2b,0x94,0xf9,0x08}, {0x26,0x9f,0xf7,0x01}, 
+{0xbd,0x46,0x4d,0xe6}, {0xb0,0x4d,0x43,0xef}, {0xa7,0x50,0x51,0xf4}, {0xaa,0x5b,0x5f,0xfd}, 
+{0x89,0x6a,0x75,0xc2}, {0x84,0x61,0x7b,0xcb}, {0x93,0x7c,0x69,0xd0}, {0x9e,0x77,0x67,0xd9}, 
+{0xd5,0x1e,0x3d,0xae}, {0xd8,0x15,0x33,0xa7}, {0xcf,0x08,0x21,0xbc}, {0xc2,0x03,0x2f,0xb5}, 
+{0xe1,0x32,0x05,0x8a}, {0xec,0x39,0x0b,0x83}, {0xfb,0x24,0x19,0x98}, {0xf6,0x2f,0x17,0x91}, 
+{0xd6,0x8d,0x76,0x4d}, {0xdb,0x86,0x78,0x44}, {0xcc,0x9b,0x6a,0x5f}, {0xc1,0x90,0x64,0x56}, 
+{0xe2,0xa1,0x4e,0x69}, {0xef,0xaa,0x40,0x60}, {0xf8,0xb7,0x52,0x7b}, {0xf5,0xbc,0x5c,0x72}, 
+{0xbe,0xd5,0x06,0x05}, {0xb3,0xde,0x08,0x0c}, {0xa4,0xc3,0x1a,0x17}, {0xa9,0xc8,0x14,0x1e}, 
+{0x8a,0xf9,0x3e,0x21}, {0x87,0xf2,0x30,0x28}, {0x90,0xef,0x22,0x33}, {0x9d,0xe4,0x2c,0x3a}, 
+{0x06,0x3d,0x96,0xdd}, {0x0b,0x36,0x98,0xd4}, {0x1c,0x2b,0x8a,0xcf}, {0x11,0x20,0x84,0xc6}, 
+{0x32,0x11,0xae,0xf9}, {0x3f,0x1a,0xa0,0xf0}, {0x28,0x07,0xb2,0xeb}, {0x25,0x0c,0xbc,0xe2}, 
+{0x6e,0x65,0xe6,0x95}, {0x63,0x6e,0xe8,0x9c}, {0x74,0x73,0xfa,0x87}, {0x79,0x78,0xf4,0x8e}, 
+{0x5a,0x49,0xde,0xb1}, {0x57,0x42,0xd0,0xb8}, {0x40,0x5f,0xc2,0xa3}, {0x4d,0x54,0xcc,0xaa}, 
+{0xda,0xf7,0x41,0xec}, {0xd7,0xfc,0x4f,0xe5}, {0xc0,0xe1,0x5d,0xfe}, {0xcd,0xea,0x53,0xf7}, 
+{0xee,0xdb,0x79,0xc8}, {0xe3,0xd0,0x77,0xc1}, {0xf4,0xcd,0x65,0xda}, {0xf9,0xc6,0x6b,0xd3}, 
+{0xb2,0xaf,0x31,0xa4}, {0xbf,0xa4,0x3f,0xad}, {0xa8,0xb9,0x2d,0xb6}, {0xa5,0xb2,0x23,0xbf}, 
+{0x86,0x83,0x09,0x80}, {0x8b,0x88,0x07,0x89}, {0x9c,0x95,0x15,0x92}, {0x91,0x9e,0x1b,0x9b}, 
+{0x0a,0x47,0xa1,0x7c}, {0x07,0x4c,0xaf,0x75}, {0x10,0x51,0xbd,0x6e}, {0x1d,0x5a,0xb3,0x67}, 
+{0x3e,0x6b,0x99,0x58}, {0x33,0x60,0x97,0x51}, {0x24,0x7d,0x85,0x4a}, {0x29,0x76,0x8b,0x43}, 
+{0x62,0x1f,0xd1,0x34}, {0x6f,0x14,0xdf,0x3d}, {0x78,0x09,0xcd,0x26}, {0x75,0x02,0xc3,0x2f}, 
+{0x56,0x33,0xe9,0x10}, {0x5b,0x38,0xe7,0x19}, {0x4c,0x25,0xf5,0x02}, {0x41,0x2e,0xfb,0x0b}, 
+{0x61,0x8c,0x9a,0xd7}, {0x6c,0x87,0x94,0xde}, {0x7b,0x9a,0x86,0xc5}, {0x76,0x91,0x88,0xcc}, 
+{0x55,0xa0,0xa2,0xf3}, {0x58,0xab,0xac,0xfa}, {0x4f,0xb6,0xbe,0xe1}, {0x42,0xbd,0xb0,0xe8}, 
+{0x09,0xd4,0xea,0x9f}, {0x04,0xdf,0xe4,0x96}, {0x13,0xc2,0xf6,0x8d}, {0x1e,0xc9,0xf8,0x84}, 
+{0x3d,0xf8,0xd2,0xbb}, {0x30,0xf3,0xdc,0xb2}, {0x27,0xee,0xce,0xa9}, {0x2a,0xe5,0xc0,0xa0}, 
+{0xb1,0x3c,0x7a,0x47}, {0xbc,0x37,0x74,0x4e}, {0xab,0x2a,0x66,0x55}, {0xa6,0x21,0x68,0x5c}, 
+{0x85,0x10,0x42,0x63}, {0x88,0x1b,0x4c,0x6a}, {0x9f,0x06,0x5e,0x71}, {0x92,0x0d,0x50,0x78}, 
+{0xd9,0x64,0x0a,0x0f}, {0xd4,0x6f,0x04,0x06}, {0xc3,0x72,0x16,0x1d}, {0xce,0x79,0x18,0x14}, 
+{0xed,0x48,0x32,0x2b}, {0xe0,0x43,0x3c,0x22}, {0xf7,0x5e,0x2e,0x39}, {0xfa,0x55,0x20,0x30}, 
+{0xb7,0x01,0xec,0x9a}, {0xba,0x0a,0xe2,0x93}, {0xad,0x17,0xf0,0x88}, {0xa0,0x1c,0xfe,0x81}, 
+{0x83,0x2d,0xd4,0xbe}, {0x8e,0x26,0xda,0xb7}, {0x99,0x3b,0xc8,0xac}, {0x94,0x30,0xc6,0xa5}, 
+{0xdf,0x59,0x9c,0xd2}, {0xd2,0x52,0x92,0xdb}, {0xc5,0x4f,0x80,0xc0}, {0xc8,0x44,0x8e,0xc9}, 
+{0xeb,0x75,0xa4,0xf6}, {0xe6,0x7e,0xaa,0xff}, {0xf1,0x63,0xb8,0xe4}, {0xfc,0x68,0xb6,0xed}, 
+{0x67,0xb1,0x0c,0x0a}, {0x6a,0xba,0x02,0x03}, {0x7d,0xa7,0x10,0x18}, {0x70,0xac,0x1e,0x11}, 
+{0x53,0x9d,0x34,0x2e}, {0x5e,0x96,0x3a,0x27}, {0x49,0x8b,0x28,0x3c}, {0x44,0x80,0x26,0x35}, 
+{0x0f,0xe9,0x7c,0x42}, {0x02,0xe2,0x72,0x4b}, {0x15,0xff,0x60,0x50}, {0x18,0xf4,0x6e,0x59}, 
+{0x3b,0xc5,0x44,0x66}, {0x36,0xce,0x4a,0x6f}, {0x21,0xd3,0x58,0x74}, {0x2c,0xd8,0x56,0x7d}, 
+{0x0c,0x7a,0x37,0xa1}, {0x01,0x71,0x39,0xa8}, {0x16,0x6c,0x2b,0xb3}, {0x1b,0x67,0x25,0xba}, 
+{0x38,0x56,0x0f,0x85}, {0x35,0x5d,0x01,0x8c}, {0x22,0x40,0x13,0x97}, {0x2f,0x4b,0x1d,0x9e}, 
+{0x64,0x22,0x47,0xe9}, {0x69,0x29,0x49,0xe0}, {0x7e,0x34,0x5b,0xfb}, {0x73,0x3f,0x55,0xf2}, 
+{0x50,0x0e,0x7f,0xcd}, {0x5d,0x05,0x71,0xc4}, {0x4a,0x18,0x63,0xdf}, {0x47,0x13,0x6d,0xd6}, 
+{0xdc,0xca,0xd7,0x31}, {0xd1,0xc1,0xd9,0x38}, {0xc6,0xdc,0xcb,0x23}, {0xcb,0xd7,0xc5,0x2a}, 
+{0xe8,0xe6,0xef,0x15}, {0xe5,0xed,0xe1,0x1c}, {0xf2,0xf0,0xf3,0x07}, {0xff,0xfb,0xfd,0x0e}, 
+{0xb4,0x92,0xa7,0x79}, {0xb9,0x99,0xa9,0x70}, {0xae,0x84,0xbb,0x6b}, {0xa3,0x8f,0xb5,0x62}, 
+{0x80,0xbe,0x9f,0x5d}, {0x8d,0xb5,0x91,0x54}, {0x9a,0xa8,0x83,0x4f}, {0x97,0xa3,0x8d,0x46}
+};
+
+static word8 U4[256][4] = {
+{0x00,0x00,0x00,0x00}, {0x09,0x0d,0x0b,0x0e}, {0x12,0x1a,0x16,0x1c}, {0x1b,0x17,0x1d,0x12}, 
+{0x24,0x34,0x2c,0x38}, {0x2d,0x39,0x27,0x36}, {0x36,0x2e,0x3a,0x24}, {0x3f,0x23,0x31,0x2a}, 
+{0x48,0x68,0x58,0x70}, {0x41,0x65,0x53,0x7e}, {0x5a,0x72,0x4e,0x6c}, {0x53,0x7f,0x45,0x62}, 
+{0x6c,0x5c,0x74,0x48}, {0x65,0x51,0x7f,0x46}, {0x7e,0x46,0x62,0x54}, {0x77,0x4b,0x69,0x5a}, 
+{0x90,0xd0,0xb0,0xe0}, {0x99,0xdd,0xbb,0xee}, {0x82,0xca,0xa6,0xfc}, {0x8b,0xc7,0xad,0xf2}, 
+{0xb4,0xe4,0x9c,0xd8}, {0xbd,0xe9,0x97,0xd6}, {0xa6,0xfe,0x8a,0xc4}, {0xaf,0xf3,0x81,0xca}, 
+{0xd8,0xb8,0xe8,0x90}, {0xd1,0xb5,0xe3,0x9e}, {0xca,0xa2,0xfe,0x8c}, {0xc3,0xaf,0xf5,0x82}, 
+{0xfc,0x8c,0xc4,0xa8}, {0xf5,0x81,0xcf,0xa6}, {0xee,0x96,0xd2,0xb4}, {0xe7,0x9b,0xd9,0xba}, 
+{0x3b,0xbb,0x7b,0xdb}, {0x32,0xb6,0x70,0xd5}, {0x29,0xa1,0x6d,0xc7}, {0x20,0xac,0x66,0xc9}, 
+{0x1f,0x8f,0x57,0xe3}, {0x16,0x82,0x5c,0xed}, {0x0d,0x95,0x41,0xff}, {0x04,0x98,0x4a,0xf1}, 
+{0x73,0xd3,0x23,0xab}, {0x7a,0xde,0x28,0xa5}, {0x61,0xc9,0x35,0xb7}, {0x68,0xc4,0x3e,0xb9}, 
+{0x57,0xe7,0x0f,0x93}, {0x5e,0xea,0x04,0x9d}, {0x45,0xfd,0x19,0x8f}, {0x4c,0xf0,0x12,0x81}, 
+{0xab,0x6b,0xcb,0x3b}, {0xa2,0x66,0xc0,0x35}, {0xb9,0x71,0xdd,0x27}, {0xb0,0x7c,0xd6,0x29}, 
+{0x8f,0x5f,0xe7,0x03}, {0x86,0x52,0xec,0x0d}, {0x9d,0x45,0xf1,0x1f}, {0x94,0x48,0xfa,0x11}, 
+{0xe3,0x03,0x93,0x4b}, {0xea,0x0e,0x98,0x45}, {0xf1,0x19,0x85,0x57}, {0xf8,0x14,0x8e,0x59}, 
+{0xc7,0x37,0xbf,0x73}, {0xce,0x3a,0xb4,0x7d}, {0xd5,0x2d,0xa9,0x6f}, {0xdc,0x20,0xa2,0x61}, 
+{0x76,0x6d,0xf6,0xad}, {0x7f,0x60,0xfd,0xa3}, {0x64,0x77,0xe0,0xb1}, {0x6d,0x7a,0xeb,0xbf}, 
+{0x52,0x59,0xda,0x95}, {0x5b,0x54,0xd1,0x9b}, {0x40,0x43,0xcc,0x89}, {0x49,0x4e,0xc7,0x87}, 
+{0x3e,0x05,0xae,0xdd}, {0x37,0x08,0xa5,0xd3}, {0x2c,0x1f,0xb8,0xc1}, {0x25,0x12,0xb3,0xcf}, 
+{0x1a,0x31,0x82,0xe5}, {0x13,0x3c,0x89,0xeb}, {0x08,0x2b,0x94,0xf9}, {0x01,0x26,0x9f,0xf7}, 
+{0xe6,0xbd,0x46,0x4d}, {0xef,0xb0,0x4d,0x43}, {0xf4,0xa7,0x50,0x51}, {0xfd,0xaa,0x5b,0x5f}, 
+{0xc2,0x89,0x6a,0x75}, {0xcb,0x84,0x61,0x7b}, {0xd0,0x93,0x7c,0x69}, {0xd9,0x9e,0x77,0x67}, 
+{0xae,0xd5,0x1e,0x3d}, {0xa7,0xd8,0x15,0x33}, {0xbc,0xcf,0x08,0x21}, {0xb5,0xc2,0x03,0x2f}, 
+{0x8a,0xe1,0x32,0x05}, {0x83,0xec,0x39,0x0b}, {0x98,0xfb,0x24,0x19}, {0x91,0xf6,0x2f,0x17}, 
+{0x4d,0xd6,0x8d,0x76}, {0x44,0xdb,0x86,0x78}, {0x5f,0xcc,0x9b,0x6a}, {0x56,0xc1,0x90,0x64}, 
+{0x69,0xe2,0xa1,0x4e}, {0x60,0xef,0xaa,0x40}, {0x7b,0xf8,0xb7,0x52}, {0x72,0xf5,0xbc,0x5c}, 
+{0x05,0xbe,0xd5,0x06}, {0x0c,0xb3,0xde,0x08}, {0x17,0xa4,0xc3,0x1a}, {0x1e,0xa9,0xc8,0x14}, 
+{0x21,0x8a,0xf9,0x3e}, {0x28,0x87,0xf2,0x30}, {0x33,0x90,0xef,0x22}, {0x3a,0x9d,0xe4,0x2c}, 
+{0xdd,0x06,0x3d,0x96}, {0xd4,0x0b,0x36,0x98}, {0xcf,0x1c,0x2b,0x8a}, {0xc6,0x11,0x20,0x84}, 
+{0xf9,0x32,0x11,0xae}, {0xf0,0x3f,0x1a,0xa0}, {0xeb,0x28,0x07,0xb2}, {0xe2,0x25,0x0c,0xbc}, 
+{0x95,0x6e,0x65,0xe6}, {0x9c,0x63,0x6e,0xe8}, {0x87,0x74,0x73,0xfa}, {0x8e,0x79,0x78,0xf4}, 
+{0xb1,0x5a,0x49,0xde}, {0xb8,0x57,0x42,0xd0}, {0xa3,0x40,0x5f,0xc2}, {0xaa,0x4d,0x54,0xcc}, 
+{0xec,0xda,0xf7,0x41}, {0xe5,0xd7,0xfc,0x4f}, {0xfe,0xc0,0xe1,0x5d}, {0xf7,0xcd,0xea,0x53}, 
+{0xc8,0xee,0xdb,0x79}, {0xc1,0xe3,0xd0,0x77}, {0xda,0xf4,0xcd,0x65}, {0xd3,0xf9,0xc6,0x6b}, 
+{0xa4,0xb2,0xaf,0x31}, {0xad,0xbf,0xa4,0x3f}, {0xb6,0xa8,0xb9,0x2d}, {0xbf,0xa5,0xb2,0x23}, 
+{0x80,0x86,0x83,0x09}, {0x89,0x8b,0x88,0x07}, {0x92,0x9c,0x95,0x15}, {0x9b,0x91,0x9e,0x1b}, 
+{0x7c,0x0a,0x47,0xa1}, {0x75,0x07,0x4c,0xaf}, {0x6e,0x10,0x51,0xbd}, {0x67,0x1d,0x5a,0xb3}, 
+{0x58,0x3e,0x6b,0x99}, {0x51,0x33,0x60,0x97}, {0x4a,0x24,0x7d,0x85}, {0x43,0x29,0x76,0x8b}, 
+{0x34,0x62,0x1f,0xd1}, {0x3d,0x6f,0x14,0xdf}, {0x26,0x78,0x09,0xcd}, {0x2f,0x75,0x02,0xc3}, 
+{0x10,0x56,0x33,0xe9}, {0x19,0x5b,0x38,0xe7}, {0x02,0x4c,0x25,0xf5}, {0x0b,0x41,0x2e,0xfb}, 
+{0xd7,0x61,0x8c,0x9a}, {0xde,0x6c,0x87,0x94}, {0xc5,0x7b,0x9a,0x86}, {0xcc,0x76,0x91,0x88}, 
+{0xf3,0x55,0xa0,0xa2}, {0xfa,0x58,0xab,0xac}, {0xe1,0x4f,0xb6,0xbe}, {0xe8,0x42,0xbd,0xb0}, 
+{0x9f,0x09,0xd4,0xea}, {0x96,0x04,0xdf,0xe4}, {0x8d,0x13,0xc2,0xf6}, {0x84,0x1e,0xc9,0xf8}, 
+{0xbb,0x3d,0xf8,0xd2}, {0xb2,0x30,0xf3,0xdc}, {0xa9,0x27,0xee,0xce}, {0xa0,0x2a,0xe5,0xc0}, 
+{0x47,0xb1,0x3c,0x7a}, {0x4e,0xbc,0x37,0x74}, {0x55,0xab,0x2a,0x66}, {0x5c,0xa6,0x21,0x68}, 
+{0x63,0x85,0x10,0x42}, {0x6a,0x88,0x1b,0x4c}, {0x71,0x9f,0x06,0x5e}, {0x78,0x92,0x0d,0x50}, 
+{0x0f,0xd9,0x64,0x0a}, {0x06,0xd4,0x6f,0x04}, {0x1d,0xc3,0x72,0x16}, {0x14,0xce,0x79,0x18}, 
+{0x2b,0xed,0x48,0x32}, {0x22,0xe0,0x43,0x3c}, {0x39,0xf7,0x5e,0x2e}, {0x30,0xfa,0x55,0x20}, 
+{0x9a,0xb7,0x01,0xec}, {0x93,0xba,0x0a,0xe2}, {0x88,0xad,0x17,0xf0}, {0x81,0xa0,0x1c,0xfe}, 
+{0xbe,0x83,0x2d,0xd4}, {0xb7,0x8e,0x26,0xda}, {0xac,0x99,0x3b,0xc8}, {0xa5,0x94,0x30,0xc6}, 
+{0xd2,0xdf,0x59,0x9c}, {0xdb,0xd2,0x52,0x92}, {0xc0,0xc5,0x4f,0x80}, {0xc9,0xc8,0x44,0x8e}, 
+{0xf6,0xeb,0x75,0xa4}, {0xff,0xe6,0x7e,0xaa}, {0xe4,0xf1,0x63,0xb8}, {0xed,0xfc,0x68,0xb6}, 
+{0x0a,0x67,0xb1,0x0c}, {0x03,0x6a,0xba,0x02}, {0x18,0x7d,0xa7,0x10}, {0x11,0x70,0xac,0x1e}, 
+{0x2e,0x53,0x9d,0x34}, {0x27,0x5e,0x96,0x3a}, {0x3c,0x49,0x8b,0x28}, {0x35,0x44,0x80,0x26}, 
+{0x42,0x0f,0xe9,0x7c}, {0x4b,0x02,0xe2,0x72}, {0x50,0x15,0xff,0x60}, {0x59,0x18,0xf4,0x6e}, 
+{0x66,0x3b,0xc5,0x44}, {0x6f,0x36,0xce,0x4a}, {0x74,0x21,0xd3,0x58}, {0x7d,0x2c,0xd8,0x56}, 
+{0xa1,0x0c,0x7a,0x37}, {0xa8,0x01,0x71,0x39}, {0xb3,0x16,0x6c,0x2b}, {0xba,0x1b,0x67,0x25}, 
+{0x85,0x38,0x56,0x0f}, {0x8c,0x35,0x5d,0x01}, {0x97,0x22,0x40,0x13}, {0x9e,0x2f,0x4b,0x1d}, 
+{0xe9,0x64,0x22,0x47}, {0xe0,0x69,0x29,0x49}, {0xfb,0x7e,0x34,0x5b}, {0xf2,0x73,0x3f,0x55}, 
+{0xcd,0x50,0x0e,0x7f}, {0xc4,0x5d,0x05,0x71}, {0xdf,0x4a,0x18,0x63}, {0xd6,0x47,0x13,0x6d}, 
+{0x31,0xdc,0xca,0xd7}, {0x38,0xd1,0xc1,0xd9}, {0x23,0xc6,0xdc,0xcb}, {0x2a,0xcb,0xd7,0xc5}, 
+{0x15,0xe8,0xe6,0xef}, {0x1c,0xe5,0xed,0xe1}, {0x07,0xf2,0xf0,0xf3}, {0x0e,0xff,0xfb,0xfd}, 
+{0x79,0xb4,0x92,0xa7}, {0x70,0xb9,0x99,0xa9}, {0x6b,0xae,0x84,0xbb}, {0x62,0xa3,0x8f,0xb5}, 
+{0x5d,0x80,0xbe,0x9f}, {0x54,0x8d,0xb5,0x91}, {0x4f,0x9a,0xa8,0x83}, {0x46,0x97,0xa3,0x8d}
+};
+
+static word32 rcon[30] = { 
+  0x01,0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91
+};

Added: experimental/j/Elphel333/rtp/daemon/rtp/btree.c
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/btree.c	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/btree.c	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,458 @@
+/*
+ * FILE:     btree.c
+ * PROGRAM:  RAT
+ * AUTHOR:   O.Hodson
+ * MODIFIED: C.Perkins
+ * 
+ * Binary tree implementation - Mostly verbatim from:
+ *
+ * Introduction to Algorithms by Corman, Leisserson, and Rivest,
+ * MIT Press / McGraw Hill, 1990.
+ *
+ */
+
+#include "config_unix.h"
+#include "config_win32.h"
+#include "debug.h"
+#include "memory.h"
+#include "btree.h"
+
+typedef struct s_btree_node {
+        uint32_t       		 key;
+        void         		*data;
+        struct s_btree_node 	*parent;
+        struct s_btree_node 	*left;
+        struct s_btree_node 	*right;
+	uint32_t		 magic;
+} btree_node_t;
+
+struct s_btree {
+        btree_node_t   *root;
+	uint32_t	magic;
+	int		count;
+};
+
+/*****************************************************************************/
+/* Debugging functions...                                                    */
+/*****************************************************************************/
+
+#define BTREE_MAGIC      0x10101010
+#define BTREE_NODE_MAGIC 0x01010101
+
+static int btree_count;
+
+static void
+btree_validate_node(btree_node_t *node, btree_node_t *parent)
+{
+	ASSERT(node->magic  == BTREE_NODE_MAGIC);
+	ASSERT(node->parent == parent);
+	btree_count++;
+	if (node->left != NULL) {
+		btree_validate_node(node->left, node);
+	}
+	if (node->right != NULL) {
+		btree_validate_node(node->right, node);
+	}
+}
+
+static void
+btree_validate(btree_t *t)
+{
+	ASSERT(t->magic == BTREE_MAGIC);
+#ifdef DEBUG
+	btree_count = 0;
+	if (t->root != NULL) {
+		btree_validate_node(t->root, NULL);
+	}
+	ASSERT(btree_count == t->count);
+#endif
+}
+
+/*****************************************************************************/
+/* Utility functions                                                         */
+/*****************************************************************************/
+
+static btree_node_t*
+btree_min(btree_node_t *x)
+{
+        if (x == NULL) {
+                return NULL;
+        }
+        while(x->left) {
+                x = x->left;
+        }
+        return x;
+}
+
+static btree_node_t*
+btree_max(btree_node_t *x)
+{
+        if (x == NULL) {
+                return NULL;
+        }
+        while(x->right) {
+                x = x->right;
+        }
+        return x;
+}
+
+static btree_node_t*
+btree_successor(btree_node_t *x)
+{
+        btree_node_t *y;
+
+        if (x->right != NULL) {
+                return btree_min(x->right);
+        }
+
+        y = x->parent;
+        while (y != NULL && x == y->right) {
+                x = y;
+                y = y->parent;
+        }
+
+        return y;
+}
+
+static btree_node_t*
+btree_search(btree_node_t *x, uint32_t key)
+{
+        while (x != NULL && key != x->key) {
+                if (key < x->key) {
+                        x = x->left;
+                } else {
+                        x = x->right;
+                }
+        }
+        return x; 
+}
+
+static void
+btree_insert_node(btree_t *tree, btree_node_t *z) {
+        btree_node_t *x, *y;
+
+	btree_validate(tree);
+        y = NULL;
+        x = tree->root;
+        while (x != NULL) {
+                y = x;
+                ASSERT(z->key != x->key);
+                if (z->key < x->key) {
+                        x = x->left;
+                } else {
+                        x = x->right;
+                }
+        }
+
+        z->parent = y;
+        if (y == NULL) {
+                tree->root = z;
+        } else if (z->key < y->key) {
+                y->left = z;
+        } else {
+                y->right = z;
+        }
+	tree->count++;
+	btree_validate(tree);
+}
+
+static btree_node_t*
+btree_delete_node(btree_t *tree, btree_node_t *z)
+{
+        btree_node_t *x, *y;
+
+	btree_validate(tree);
+        if (z->left == NULL || z->right == NULL) {
+                y = z;
+        } else {
+                y = btree_successor(z);
+        }
+
+        if (y->left != NULL) {
+                x = y->left;
+        } else {
+                x = y->right;
+        }
+
+        if (x != NULL) {
+                x->parent = y->parent;
+        }
+
+        if (y->parent == NULL) {
+                tree->root = x;
+        } else if (y == y->parent->left) {
+                y->parent->left = x;
+        } else {
+                y->parent->right = x;
+        }
+
+        z->key  = y->key;
+        z->data = y->data;
+
+	tree->count--;
+
+	btree_validate(tree);
+        return y;
+}
+
+/*****************************************************************************/
+/* Exported functions                                                        */
+/*****************************************************************************/
+
+int
+btree_create(btree_t **tree)
+{
+        btree_t *t = (btree_t*)xmalloc(sizeof(btree_t));
+        if (t) {
+		t->count = 0;
+		t->magic = BTREE_MAGIC;
+                t->root  = NULL;
+                *tree = t;
+                return TRUE;
+        }
+        return FALSE;
+}
+
+int
+btree_destroy(btree_t **tree)
+{
+        btree_t *t = *tree;
+
+	btree_validate(t);
+        if (t->root != NULL) {
+                debug_msg("Tree not empty - cannot destroy\n");
+                return FALSE;
+        }
+
+        xfree(t);
+        *tree = NULL;
+        return TRUE;
+}
+
+int
+btree_find(btree_t *tree, uint32_t key, void **d)
+{
+        btree_node_t *x;
+
+	btree_validate(tree);
+        x = btree_search(tree->root, key);
+        if (x != NULL) {
+                *d = x->data;
+                return TRUE;
+        }
+        return FALSE;
+}
+
+int 
+btree_add(btree_t *tree, uint32_t key, void *data)
+{
+        btree_node_t *x;
+
+	btree_validate(tree);
+        x = btree_search(tree->root, key);
+        if (x != NULL) {
+                debug_msg("Item already exists - key %ul\n", key);
+                return FALSE;
+        }
+
+        x = (btree_node_t *)xmalloc(sizeof(btree_node_t));
+        x->key    = key;
+        x->data   = data;
+        x->parent = NULL;
+	x->left   = NULL;
+	x->right  = NULL;
+	x->magic  = BTREE_NODE_MAGIC;
+        btree_insert_node(tree, x);
+
+        return TRUE;
+}
+
+int
+btree_remove(btree_t *tree, uint32_t key, void **data)
+{
+        btree_node_t *x;
+
+	btree_validate(tree);
+        x = btree_search(tree->root, key);
+        if (x == NULL) {
+                debug_msg("Item not on tree - key %ul\n", key);
+                *data = NULL;
+                return FALSE;
+        }
+
+        /* Note value that gets freed is not necessarily the the same
+         * as node that gets removed from tree since there is an
+         * optimization to avoid pointer updates in tree which means
+         * sometimes we just copy key and data from one node to
+         * another.  
+         */
+
+        *data = x->data;
+        x = btree_delete_node(tree, x);
+        xfree(x);
+
+        return TRUE;
+}
+
+int 
+btree_get_min_key(btree_t *tree, uint32_t *key)
+{
+        btree_node_t *x;
+
+	btree_validate(tree);
+        if (tree->root == NULL) {
+                return FALSE;
+        }
+
+        x = btree_min(tree->root);
+        if (x == NULL) {
+                return FALSE;
+        }
+        
+        *key = x->key;
+        return TRUE;
+}
+
+int 
+btree_get_max_key(btree_t *tree, uint32_t *key)
+{
+        btree_node_t *x;
+
+	btree_validate(tree);
+        if (tree->root == NULL) {
+                return FALSE;
+        }
+
+        x = btree_max(tree->root);
+        if (x == NULL) {
+                return FALSE;
+        }
+        
+        *key = x->key;
+        return TRUE;
+}
+
+int
+btree_get_next_key(btree_t *tree, uint32_t cur_key, uint32_t *next_key)
+{
+        btree_node_t *x;
+
+	btree_validate(tree);
+        x = btree_search(tree->root, cur_key);
+        if (x == NULL) {
+                return FALSE;
+        }
+        
+        x = btree_successor(x);
+        if (x == NULL) {
+                return FALSE;
+        }
+        
+        *next_key = x->key;
+        return TRUE;
+}
+
+/*****************************************************************************/
+/* Test code                                                                 */
+/*****************************************************************************/
+
+#ifdef TEST_BTREE
+
+static int
+btree_depth(btree_node_t *x)
+{
+        int l, r;
+
+        if (x == NULL) {
+                return 0;
+        }
+
+        l = btree_depth(x->left);
+        r = btree_depth(x->right);
+
+        if (l > r) {
+                return l + 1;
+        } else {
+                return r + 1;
+        }
+}
+
+#include <curses.h>
+
+static void
+btree_dump_node(btree_node_t *x, int depth, int c, int w)
+{
+        if (x == NULL) {
+                return;
+        }
+        
+        move(depth * 2, c);
+        printw("%lu", x->key);
+        refresh();
+
+        btree_dump_node(x->left,  depth + 1, c - w/2, w/2);
+        btree_dump_node(x->right, depth + 1, c + w/2, w/2);
+
+        return;
+}
+
+static void
+btree_dump(btree_t *b)
+{
+        initscr();
+        btree_dump_node(b->root, 0, 40, 48);
+        refresh();
+        endwin();
+}
+
+#include "stdlib.h"
+
+int 
+main()
+{
+        btree_t *b;
+        uint32_t i, *x;
+        uint32_t v[] = {15, 5, 16, 3, 12, 20, 10, 13, 18, 23, 6, 7}; 
+        uint32_t nv = sizeof(v) / sizeof(v[0]);
+
+        btree_create(&b);
+
+        for(i = 0; i < nv; i++) {
+                x = (uint32_t*)xmalloc(sizeof(uint32_t));
+                *x = (uint32_t)random();
+                if (btree_add(b, v[i], (void*)x) != TRUE) {
+                        printf("Fail Add %lu %lu\n", v[i], *x);
+                }
+        }
+    
+        printf("depth %d\n", btree_depth(b->root));
+        btree_dump(b);
+
+        sleep(3);
+        btree_remove(b, 5, (void*)&x);
+        btree_dump(b);
+        sleep(3);
+        btree_remove(b, 16, (void*)&x);
+        btree_dump(b);
+        sleep(3);
+        btree_remove(b, 13, (void*)&x);
+        btree_dump(b);
+
+        while (btree_get_root_key(b, &i)) {
+                if (btree_remove(b, i, (void*)&x) == FALSE) {
+                        fprintf(stderr, "Failed to remove %lu\n", i);
+                }
+                btree_dump(b);
+                sleep(1); 
+        }
+
+        if (btree_destroy(&b) == FALSE) {
+                printf("Failed to destroy \n");
+        }
+                
+        return 0;
+}
+
+#endif /* TEST_BTREE*/
+
+

Added: experimental/j/Elphel333/rtp/daemon/rtp/btree.h
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/btree.h	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/btree.h	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,63 @@
+/*
+ * FILE:    btree.h
+ * PROGRAM: RAT
+ * AUTHOR:  O.Hodson
+ * 
+ * Binary tree implementation - Mostly verbatim from:
+ *
+ * Introduction to Algorithms by Corman, Leisserson, and Rivest,
+ * MIT Press / McGraw Hill, 1990.
+ *
+ * Implementation assumes one data element per key is assigned.
+ *
+ * Thanks to Markus Geimeier <mager at tzi.de> for pointing out want
+ * btree_get_min_key and not btree_get_root_key for start point for tree
+ * iteration.
+ * 
+ */
+
+#ifndef __BTREE_H__
+#define __BTREE_H__
+
+typedef struct s_btree btree_t;
+
+/* btree_create fills the *tree with a new binary tree.  Returns TRUE on     */
+/* success and FALSE on failure.                                             */
+
+int  btree_create  (btree_t **tree);
+
+/* btree_destroy destroys tree.  If tree is not empty it cannot be destroyed */
+/* and call returns FALSE.  On success returns TRUE.                         */
+
+int btree_destroy (btree_t **tree);
+ 
+/* btree_add adds data for key to tree.  Returns TRUE on success, or FALSE   */
+/* if key is already on tree.  */
+
+int btree_add    (btree_t *tree, uint32_t key, void *data);
+
+/* btree_remove attempts to remove data from tree.  Returns TRUE on success  */
+/* and points *d at value stored for key.  FALSE is returned if key is not   */
+/* on tree.                                                                  */
+
+int btree_remove (btree_t *tree, uint32_t key, void **d);
+
+/* btree_find locates data for key and make *d point to it.  Returns TRUE if */
+/* data for key is found, FALSE otherwise.                                   */
+
+int btree_find   (btree_t *tree, uint32_t key, void **d);
+
+/* btree_get_min_key attempts to return minimum key of tree.  Function       */
+/* intended to help if list of keys is not stored elsewhere.  Returns TRUE   */
+/* and fills key with key if possible, FALSE otherwise                       */
+
+int btree_get_min_key (btree_t *tree, uint32_t *key);
+int btree_get_max_key (btree_t *tree, uint32_t *key);
+
+/* btree_get_next_key attempts to get the key above cur_key.  Returns        */
+/* TRUE and fills key with key if possible, FALSE otherwise.                 */
+
+int btree_get_next_key (btree_t *tree, uint32_t cur_key, uint32_t *next_key);
+
+#endif /* __BTREE_H__ */
+

Added: experimental/j/Elphel333/rtp/daemon/rtp/cdecl_ext.h
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/cdecl_ext.h	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/cdecl_ext.h	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 1999 WIDE Project.
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#ifndef HAVE_PORTABLE_PROTOTYPE
+
+#ifndef __P
+#if defined(__STDC__) || defined(__cplusplus) 
+#define	__P(protos)	protos		/* full-blown ANSI C */
+#else
+#define	__P(protos)	()		/* traditional C preprocessor */
+#endif
+#endif
+
+#endif /* !HAVE_PORTABLE_PROTOTYPE */

Added: experimental/j/Elphel333/rtp/daemon/rtp/common60.dsp
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/common60.dsp	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/common60.dsp	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,439 @@
+# Microsoft Developer Studio Project File - Name="common" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Static Library" 0x0104
+
+CFG=common - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "common60.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "common60.mak" CFG="common - Win32 Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "common - Win32 Release" (based on "Win32 (x86) Static Library")
+!MESSAGE "common - Win32 Debug IPv6" (based on "Win32 (x86) Static Library")
+!MESSAGE "common - Win32 Debug IPv6 Musica" (based on "Win32 (x86) Static Library")
+!MESSAGE "common - Win32 Debug" (based on "Win32 (x86) Static Library")
+!MESSAGE 
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "common - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\tcl-8.0\generic" /I "..\tk-8.0\generic" /I "..\tk-8.0\xlib" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "HAVE_INET_NTOP" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo /out:"Release\uclmm.lib"
+
+!ELSEIF  "$(CFG)" == "common - Win32 Debug IPv6"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "common___Win32_Debug_IPv6"
+# PROP BASE Intermediate_Dir "common___Win32_Debug_IPv6"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug_IPv6"
+# PROP Intermediate_Dir "Debug_IPv6"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /ZI /Od /I "\src\tcl-8.0\generic" /I "\src\tk-8.0\generic" /I "\src\tk-8.0\xlib" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "DEBUG" /D "DEBUG_MEM" /FR /YX /FD /GZ /c
+# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "\src\tcl-8.0\generic" /I "\src\tk-8.0\generic" /I "\src\tk-8.0\xlib" /I "\DDK\inc" /I "\src\IPv6Kit\inc" /I "..\tcl-8.0\generic" /I "..\tk-8.0\generic" /I "..\tk-8.0\xlib" /I "..\ipv6kit\inc" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "DEBUG" /D "DEBUG_MEM" /D "HAVE_IPv6" /D "BUILD_tcl" /D "BUILD_tk" /D "NEED_IN6_IS_ADDR_MULTICAST" /D "HAVE_INET_PTON" /D "HAVE_INET_NTOP" /FR /YX /FD /GZ /GZ /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo /out:"Debug\uclmm.lib"
+# ADD LIB32 /nologo /out:"Debug_IPv6\uclmm.lib"
+
+!ELSEIF  "$(CFG)" == "common - Win32 Debug IPv6 Musica"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "common___Win32_Debug_IPv6_Musica"
+# PROP BASE Intermediate_Dir "common___Win32_Debug_IPv6_Musica"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug_IPv6_Musica"
+# PROP Intermediate_Dir "Debug_IPv6_Musica"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /I "\src\tcl-8.0\generic" /I "\src\tk-8.0\generic" /I "\src\tk-8.0\xlib" /I "\DDK\inc" /I "\src\MSR_IPv6_1.3\inc" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "DEBUG" /D "DEBUG_MEM" /D "HAVE_IPv6" /D "BUILD_tcl" /D "BUILD_tk" /FR /YX /FD /GZ /c
+# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\tcl-8.0\generic" /I "..\tk-8.0\generic" /I "..\tk-8.0\xlib" /I "..\MUSICA\WINSOCK6" /D "_MBCS" /D "_LIB" /D "DEBUG_MEM" /D "BUILD_tcl" /D "BUILD_tk" /D "DEBUG" /D "WIN32" /D "_DEBUG" /D "HAVE_IPv6" /D "MUSICA_IPV6" /D "_WINNT" /D "_POSIX" /D "NEED_ADDRINFO_H" /D "NEED_IN_EXPERIMENTAL" /D "NEED_IN6_IS_ADDR_V4MAPPED" /FR /YX /FD /GZ /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo /out:"Debug\uclmm.lib"
+# ADD LIB32 /nologo /out:"Debug\uclmm.lib"
+
+!ELSEIF  "$(CFG)" == "common - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /GX /Zi /Od /I "..\tcl-8.0\generic" /I "..\tk-8.0\generic" /I "..\tk-8.0\xlib" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "DEBUG" /FR /YX /FD /GZ /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo /out:"Debug\uclmm.lib"
+
+!ENDIF 
+
+# Begin Target
+
+# Name "common - Win32 Release"
+# Name "common - Win32 Debug IPv6"
+# Name "common - Win32 Debug IPv6 Musica"
+# Name "common - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\asarray.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\base64.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\btree.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\crypt_random.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\debug.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\drand48.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\getaddrinfo.c
+
+!IF  "$(CFG)" == "common - Win32 Release"
+
+# PROP Exclude_From_Build 1
+
+!ELSEIF  "$(CFG)" == "common - Win32 Debug IPv6"
+
+# PROP Exclude_From_Build 1
+
+!ELSEIF  "$(CFG)" == "common - Win32 Debug IPv6 Musica"
+
+# ADD CPP /D "INET6" /D "HAVE_GETHOSTBYNAME2"
+
+!ELSEIF  "$(CFG)" == "common - Win32 Debug"
+
+# PROP Exclude_From_Build 1
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\gettimeofday.c
+
+!IF  "$(CFG)" == "common - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "common - Win32 Debug IPv6"
+
+!ELSEIF  "$(CFG)" == "common - Win32 Debug IPv6 Musica"
+
+# ADD CPP /W4
+
+!ELSEIF  "$(CFG)" == "common - Win32 Debug"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\hmac.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\inet_ntop.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\inet_pton.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\mbus.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\mbus_addr.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\mbus_config.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\mbus_parser.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\md5.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\memory.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\net_udp.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\ntp.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\qfDES.c
+
+!IF  "$(CFG)" == "common - Win32 Release"
+
+# SUBTRACT CPP /O<none>
+
+!ELSEIF  "$(CFG)" == "common - Win32 Debug IPv6"
+
+!ELSEIF  "$(CFG)" == "common - Win32 Debug IPv6 Musica"
+
+!ELSEIF  "$(CFG)" == "common - Win32 Debug"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=".\rijndael-alg-fst.c"
+# End Source File
+# Begin Source File
+
+SOURCE=".\rijndael-api-fst.c"
+# End Source File
+# Begin Source File
+
+SOURCE=.\rtp.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\util.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\acconfig.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\addrinfo.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\addrsize.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\asarray.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\base64.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\bittypes.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\btree.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\cdecl_ext.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\config_win32.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\crypt_random.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\debug.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\drand48.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\gettimeofday.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\hmac.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\inet_ntop.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\inet_pton.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\mbus.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\mbus_addr.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\mbus_config.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\mbus_parser.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\md5.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\memory.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\net_udp.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\ntp.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\qfDES.h
+# End Source File
+# Begin Source File
+
+SOURCE=".\rijndael-alg-fst.h"
+# End Source File
+# Begin Source File
+
+SOURCE=".\rijndael-api-fst.h"
+# End Source File
+# Begin Source File
+
+SOURCE=.\rtp.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\sockstorage.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\test_base64.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\test_des.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\test_mbus_addr.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\test_mbus_parser.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\test_md5.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\test_memory.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\test_net_udp.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\util.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\version.h
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\VERSION
+# End Source File
+# End Target
+# End Project

Added: experimental/j/Elphel333/rtp/daemon/rtp/config.guess
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/config.guess	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/config.guess	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,1317 @@
+#! /bin/sh
+# Attempt to guess a canonical system name.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+#   Free Software Foundation, Inc.
+
+timestamp='2001-09-04'
+
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Written by Per Bothner <bothner at cygnus.com>.
+# Please send patches to <config-patches at gnu.org>.
+#
+# This script attempts to guess a canonical system name similar to
+# config.sub.  If it succeeds, it prints the system name on stdout, and
+# exits with 0.  Otherwise, it exits with 1.
+#
+# The plan is that this can be called by configure scripts if you
+# don't specify an explicit build system type.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of the system \`$me' is run on.
+
+Operation modes:
+  -h, --help         print this help, then exit
+  -t, --time-stamp   print date of last modification, then exit
+  -v, --version      print version number, then exit
+
+Report bugs and patches to <config-patches at gnu.org>."
+
+version="\
+GNU config.guess ($timestamp)
+
+Originally written by Per Bothner.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+  case $1 in
+    --time-stamp | --time* | -t )
+       echo "$timestamp" ; exit 0 ;;
+    --version | -v )
+       echo "$version" ; exit 0 ;;
+    --help | --h* | -h )
+       echo "$usage"; exit 0 ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )	# Use stdin as input.
+       break ;;
+    -* )
+       echo "$me: invalid option $1$help" >&2
+       exit 1 ;;
+    * )
+       break ;;
+  esac
+done
+
+if test $# != 0; then
+  echo "$me: too many arguments$help" >&2
+  exit 1
+fi
+
+
+dummy=dummy-$$
+trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15
+
+# CC_FOR_BUILD -- compiler used by this script.
+# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
+# use `HOST_CC' if defined, but it is deprecated.
+
+set_cc_for_build='case $CC_FOR_BUILD,$HOST_CC,$CC in
+ ,,)    echo "int dummy(){}" > $dummy.c ;
+	for c in cc gcc c89 ; do
+	  ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 ;
+	  if test $? = 0 ; then
+	     CC_FOR_BUILD="$c"; break ;
+	  fi ;
+	done ;
+	rm -f $dummy.c $dummy.o $dummy.rel ;
+	if test x"$CC_FOR_BUILD" = x ; then
+	  CC_FOR_BUILD=no_compiler_found ;
+	fi
+	;;
+ ,,*)   CC_FOR_BUILD=$CC ;;
+ ,*,*)  CC_FOR_BUILD=$HOST_CC ;;
+esac'
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi at noc.rutgers.edu 1994-08-24)
+if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
+	PATH=$PATH:/.attbin ; export PATH
+fi
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+# Note: order is significant - the case branches are not exclusive.
+
+case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+    *:NetBSD:*:*)
+	# Netbsd (nbsd) targets should (where applicable) match one or
+	# more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+	# *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
+	# switched to ELF, *-*-netbsd* would select the old
+	# object file format.  This provides both forward
+	# compatibility and a consistent mechanism for selecting the
+	# object file format.
+	# Determine the machine/vendor (is the vendor relevant).
+	case "${UNAME_MACHINE}" in
+	    amiga) machine=m68k-unknown ;;
+	    arm32) machine=arm-unknown ;;
+	    atari*) machine=m68k-atari ;;
+	    sun3*) machine=m68k-sun ;;
+	    mac68k) machine=m68k-apple ;;
+	    macppc) machine=powerpc-apple ;;
+	    hp3[0-9][05]) machine=m68k-hp ;;
+	    ibmrt|romp-ibm) machine=romp-ibm ;;
+	    *) machine=${UNAME_MACHINE}-unknown ;;
+	esac
+	# The Operating System including object format, if it has switched
+	# to ELF recently, or will in the future.
+	case "${UNAME_MACHINE}" in
+	    i386|sparc|amiga|arm*|hp300|mvme68k|vax|atari|luna68k|mac68k|news68k|next68k|pc532|sun3*|x68k)
+		eval $set_cc_for_build
+		if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+			| grep __ELF__ >/dev/null
+		then
+		    # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+		    # Return netbsd for either.  FIX?
+		    os=netbsd
+		else
+		    os=netbsdelf
+		fi
+		;;
+	    *)
+	        os=netbsd
+		;;
+	esac
+	# The OS release
+	release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+	# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+	# contains redundant information, the shorter form:
+	# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+	echo "${machine}-${os}${release}"
+	exit 0 ;;
+    alpha:OSF1:*:*)
+	if test $UNAME_RELEASE = "V4.0"; then
+		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+	fi
+	# A Vn.n version is a released version.
+	# A Tn.n version is a released field test version.
+	# A Xn.n version is an unreleased experimental baselevel.
+	# 1.2 uses "1.2" for uname -r.
+	cat <<EOF >$dummy.s
+	.data
+\$Lformat:
+	.byte 37,100,45,37,120,10,0	# "%d-%x\n"
+
+	.text
+	.globl main
+	.align 4
+	.ent main
+main:
+	.frame \$30,16,\$26,0
+	ldgp \$29,0(\$27)
+	.prologue 1
+	.long 0x47e03d80 # implver \$0
+	lda \$2,-1
+	.long 0x47e20c21 # amask \$2,\$1
+	lda \$16,\$Lformat
+	mov \$0,\$17
+	not \$1,\$18
+	jsr \$26,printf
+	ldgp \$29,0(\$26)
+	mov 0,\$16
+	jsr \$26,exit
+	.end main
+EOF
+	eval $set_cc_for_build
+	$CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
+	if test "$?" = 0 ; then
+		case `./$dummy` in
+			0-0)
+				UNAME_MACHINE="alpha"
+				;;
+			1-0)
+				UNAME_MACHINE="alphaev5"
+				;;
+			1-1)
+				UNAME_MACHINE="alphaev56"
+				;;
+			1-101)
+				UNAME_MACHINE="alphapca56"
+				;;
+			2-303)
+				UNAME_MACHINE="alphaev6"
+				;;
+			2-307)
+				UNAME_MACHINE="alphaev67"
+				;;
+			2-1307)
+				UNAME_MACHINE="alphaev68"
+				;;
+		esac
+	fi
+	rm -f $dummy.s $dummy
+	echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+	exit 0 ;;
+    Alpha\ *:Windows_NT*:*)
+	# How do we know it's Interix rather than the generic POSIX subsystem?
+	# Should we change UNAME_MACHINE based on the output of uname instead
+	# of the specific Alpha model?
+	echo alpha-pc-interix
+	exit 0 ;;
+    21064:Windows_NT:50:3)
+	echo alpha-dec-winnt3.5
+	exit 0 ;;
+    Amiga*:UNIX_System_V:4.0:*)
+	echo m68k-unknown-sysv4
+	exit 0;;
+    amiga:OpenBSD:*:*)
+	echo m68k-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    *:[Aa]miga[Oo][Ss]:*:*)
+	echo ${UNAME_MACHINE}-unknown-amigaos
+	exit 0 ;;
+    arc64:OpenBSD:*:*)
+	echo mips64el-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    arc:OpenBSD:*:*)
+	echo mipsel-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    hkmips:OpenBSD:*:*)
+	echo mips-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    pmax:OpenBSD:*:*)
+	echo mipsel-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    sgi:OpenBSD:*:*)
+	echo mips-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    wgrisc:OpenBSD:*:*)
+	echo mipsel-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    *:OS/390:*:*)
+	echo i370-ibm-openedition
+	exit 0 ;;
+    arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+	echo arm-acorn-riscix${UNAME_RELEASE}
+	exit 0;;
+    SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
+	echo hppa1.1-hitachi-hiuxmpp
+	exit 0;;
+    Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
+	# akee at wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
+	if test "`(/bin/universe) 2>/dev/null`" = att ; then
+		echo pyramid-pyramid-sysv3
+	else
+		echo pyramid-pyramid-bsd
+	fi
+	exit 0 ;;
+    NILE*:*:*:dcosx)
+	echo pyramid-pyramid-svr4
+	exit 0 ;;
+    sun4H:SunOS:5.*:*)
+	echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit 0 ;;
+    sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
+	echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit 0 ;;
+    i86pc:SunOS:5.*:*)
+	echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit 0 ;;
+    sun4*:SunOS:6*:*)
+	# According to config.sub, this is the proper way to canonicalize
+	# SunOS6.  Hard to guess exactly what SunOS6 will be like, but
+	# it's likely to be more like Solaris than SunOS4.
+	echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit 0 ;;
+    sun4*:SunOS:*:*)
+	case "`/usr/bin/arch -k`" in
+	    Series*|S4*)
+		UNAME_RELEASE=`uname -v`
+		;;
+	esac
+	# Japanese Language versions have a version number like `4.1.3-JL'.
+	echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+	exit 0 ;;
+    sun3*:SunOS:*:*)
+	echo m68k-sun-sunos${UNAME_RELEASE}
+	exit 0 ;;
+    sun*:*:4.2BSD:*)
+	UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+	test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+	case "`/bin/arch`" in
+	    sun3)
+		echo m68k-sun-sunos${UNAME_RELEASE}
+		;;
+	    sun4)
+		echo sparc-sun-sunos${UNAME_RELEASE}
+		;;
+	esac
+	exit 0 ;;
+    aushp:SunOS:*:*)
+	echo sparc-auspex-sunos${UNAME_RELEASE}
+	exit 0 ;;
+    sparc*:NetBSD:*)
+	echo `uname -p`-unknown-netbsd${UNAME_RELEASE}
+	exit 0 ;;
+    atari*:OpenBSD:*:*)
+	echo m68k-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    # The situation for MiNT is a little confusing.  The machine name
+    # can be virtually everything (everything which is not
+    # "atarist" or "atariste" at least should have a processor
+    # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
+    # to the lowercase version "mint" (or "freemint").  Finally
+    # the system name "TOS" denotes a system which is actually not
+    # MiNT.  But MiNT is downward compatible to TOS, so this should
+    # be no problem.
+    atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
+        echo m68k-atari-mint${UNAME_RELEASE}
+	exit 0 ;;
+    atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+	echo m68k-atari-mint${UNAME_RELEASE}
+        exit 0 ;;
+    *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+        echo m68k-atari-mint${UNAME_RELEASE}
+	exit 0 ;;
+    milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+        echo m68k-milan-mint${UNAME_RELEASE}
+        exit 0 ;;
+    hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+        echo m68k-hades-mint${UNAME_RELEASE}
+        exit 0 ;;
+    *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+        echo m68k-unknown-mint${UNAME_RELEASE}
+        exit 0 ;;
+    sun3*:OpenBSD:*:*)
+	echo m68k-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    mac68k:OpenBSD:*:*)
+	echo m68k-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    mvme68k:OpenBSD:*:*)
+	echo m68k-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    mvme88k:OpenBSD:*:*)
+	echo m88k-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    powerpc:machten:*:*)
+	echo powerpc-apple-machten${UNAME_RELEASE}
+	exit 0 ;;
+    RISC*:Mach:*:*)
+	echo mips-dec-mach_bsd4.3
+	exit 0 ;;
+    RISC*:ULTRIX:*:*)
+	echo mips-dec-ultrix${UNAME_RELEASE}
+	exit 0 ;;
+    VAX*:ULTRIX*:*:*)
+	echo vax-dec-ultrix${UNAME_RELEASE}
+	exit 0 ;;
+    2020:CLIX:*:* | 2430:CLIX:*:*)
+	echo clipper-intergraph-clix${UNAME_RELEASE}
+	exit 0 ;;
+    mips:*:*:UMIPS | mips:*:*:RISCos)
+	eval $set_cc_for_build
+	sed 's/^	//' << EOF >$dummy.c
+#ifdef __cplusplus
+#include <stdio.h>  /* for printf() prototype */
+	int main (int argc, char *argv[]) {
+#else
+	int main (argc, argv) int argc; char *argv[]; {
+#endif
+	#if defined (host_mips) && defined (MIPSEB)
+	#if defined (SYSTYPE_SYSV)
+	  printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
+	#endif
+	#if defined (SYSTYPE_SVR4)
+	  printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
+	#endif
+	#if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
+	  printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
+	#endif
+	#endif
+	  exit (-1);
+	}
+EOF
+	$CC_FOR_BUILD $dummy.c -o $dummy \
+	  && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
+	  && rm -f $dummy.c $dummy && exit 0
+	rm -f $dummy.c $dummy
+	echo mips-mips-riscos${UNAME_RELEASE}
+	exit 0 ;;
+    Motorola:PowerMAX_OS:*:*)
+	echo powerpc-motorola-powermax
+	exit 0 ;;
+    Night_Hawk:Power_UNIX:*:*)
+	echo powerpc-harris-powerunix
+	exit 0 ;;
+    m88k:CX/UX:7*:*)
+	echo m88k-harris-cxux7
+	exit 0 ;;
+    m88k:*:4*:R4*)
+	echo m88k-motorola-sysv4
+	exit 0 ;;
+    m88k:*:3*:R3*)
+	echo m88k-motorola-sysv3
+	exit 0 ;;
+    AViiON:dgux:*:*)
+        # DG/UX returns AViiON for all architectures
+        UNAME_PROCESSOR=`/usr/bin/uname -p`
+	if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
+	then
+	    if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
+	       [ ${TARGET_BINARY_INTERFACE}x = x ]
+	    then
+		echo m88k-dg-dgux${UNAME_RELEASE}
+	    else
+		echo m88k-dg-dguxbcs${UNAME_RELEASE}
+	    fi
+	else
+	    echo i586-dg-dgux${UNAME_RELEASE}
+	fi
+ 	exit 0 ;;
+    M88*:DolphinOS:*:*)	# DolphinOS (SVR3)
+	echo m88k-dolphin-sysv3
+	exit 0 ;;
+    M88*:*:R3*:*)
+	# Delta 88k system running SVR3
+	echo m88k-motorola-sysv3
+	exit 0 ;;
+    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+	echo m88k-tektronix-sysv3
+	exit 0 ;;
+    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+	echo m68k-tektronix-bsd
+	exit 0 ;;
+    *:IRIX*:*:*)
+	echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+	exit 0 ;;
+    ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+	echo romp-ibm-aix      # uname -m gives an 8 hex-code CPU id
+	exit 0 ;;              # Note that: echo "'`uname -s`'" gives 'AIX '
+    i*86:AIX:*:*)
+	echo i386-ibm-aix
+	exit 0 ;;
+    ia64:AIX:*:*)
+	if [ -x /usr/bin/oslevel ] ; then
+		IBM_REV=`/usr/bin/oslevel`
+	else
+		IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+	fi
+	echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
+	exit 0 ;;
+    *:AIX:2:3)
+	if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+		eval $set_cc_for_build
+		sed 's/^		//' << EOF >$dummy.c
+		#include <sys/systemcfg.h>
+
+		main()
+			{
+			if (!__power_pc())
+				exit(1);
+			puts("powerpc-ibm-aix3.2.5");
+			exit(0);
+			}
+EOF
+		$CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0
+		rm -f $dummy.c $dummy
+		echo rs6000-ibm-aix3.2.5
+	elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
+		echo rs6000-ibm-aix3.2.4
+	else
+		echo rs6000-ibm-aix3.2
+	fi
+	exit 0 ;;
+    *:AIX:*:[45])
+	IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'`
+	if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
+		IBM_ARCH=rs6000
+	else
+		IBM_ARCH=powerpc
+	fi
+	if [ -x /usr/bin/oslevel ] ; then
+		IBM_REV=`/usr/bin/oslevel`
+	else
+		IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+	fi
+	echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+	exit 0 ;;
+    *:AIX:*:*)
+	echo rs6000-ibm-aix
+	exit 0 ;;
+    ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+	echo romp-ibm-bsd4.4
+	exit 0 ;;
+    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
+	echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to
+	exit 0 ;;                           # report: romp-ibm BSD 4.3
+    *:BOSX:*:*)
+	echo rs6000-bull-bosx
+	exit 0 ;;
+    DPX/2?00:B.O.S.:*:*)
+	echo m68k-bull-sysv3
+	exit 0 ;;
+    9000/[34]??:4.3bsd:1.*:*)
+	echo m68k-hp-bsd
+	exit 0 ;;
+    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+	echo m68k-hp-bsd4.4
+	exit 0 ;;
+    9000/[34678]??:HP-UX:*:*)
+	HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+	case "${UNAME_MACHINE}" in
+	    9000/31? )            HP_ARCH=m68000 ;;
+	    9000/[34]?? )         HP_ARCH=m68k ;;
+	    9000/[678][0-9][0-9])
+              case "${HPUX_REV}" in
+                11.[0-9][0-9])
+                  if [ -x /usr/bin/getconf ]; then
+                    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
+                    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+                    case "${sc_cpu_version}" in
+                      523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
+                      528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+                      532)                      # CPU_PA_RISC2_0
+                        case "${sc_kernel_bits}" in
+                          32) HP_ARCH="hppa2.0n" ;;
+                          64) HP_ARCH="hppa2.0w" ;;
+                        esac ;;
+                    esac
+                  fi ;;
+              esac
+              if [ "${HP_ARCH}" = "" ]; then
+	      eval $set_cc_for_build
+              sed 's/^              //' << EOF >$dummy.c
+
+              #define _HPUX_SOURCE
+              #include <stdlib.h>
+              #include <unistd.h>
+
+              int main ()
+              {
+              #if defined(_SC_KERNEL_BITS)
+                  long bits = sysconf(_SC_KERNEL_BITS);
+              #endif
+                  long cpu  = sysconf (_SC_CPU_VERSION);
+
+                  switch (cpu)
+              	{
+              	case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+              	case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+              	case CPU_PA_RISC2_0:
+              #if defined(_SC_KERNEL_BITS)
+              	    switch (bits)
+              		{
+              		case 64: puts ("hppa2.0w"); break;
+              		case 32: puts ("hppa2.0n"); break;
+              		default: puts ("hppa2.0"); break;
+              		} break;
+              #else  /* !defined(_SC_KERNEL_BITS) */
+              	    puts ("hppa2.0"); break;
+              #endif
+              	default: puts ("hppa1.0"); break;
+              	}
+                  exit (0);
+              }
+EOF
+	    (CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy`
+	    if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi
+	    rm -f $dummy.c $dummy
+	fi ;;
+	esac
+	echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+	exit 0 ;;
+    ia64:HP-UX:*:*)
+	HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+	echo ia64-hp-hpux${HPUX_REV}
+	exit 0 ;;
+    3050*:HI-UX:*:*)
+	eval $set_cc_for_build
+	sed 's/^	//' << EOF >$dummy.c
+	#include <unistd.h>
+	int
+	main ()
+	{
+	  long cpu = sysconf (_SC_CPU_VERSION);
+	  /* The order matters, because CPU_IS_HP_MC68K erroneously returns
+	     true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
+	     results, however.  */
+	  if (CPU_IS_PA_RISC (cpu))
+	    {
+	      switch (cpu)
+		{
+		  case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
+		  case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
+		  case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
+		  default: puts ("hppa-hitachi-hiuxwe2"); break;
+		}
+	    }
+	  else if (CPU_IS_HP_MC68K (cpu))
+	    puts ("m68k-hitachi-hiuxwe2");
+	  else puts ("unknown-hitachi-hiuxwe2");
+	  exit (0);
+	}
+EOF
+	$CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0
+	rm -f $dummy.c $dummy
+	echo unknown-hitachi-hiuxwe2
+	exit 0 ;;
+    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+	echo hppa1.1-hp-bsd
+	exit 0 ;;
+    9000/8??:4.3bsd:*:*)
+	echo hppa1.0-hp-bsd
+	exit 0 ;;
+    *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
+	echo hppa1.0-hp-mpeix
+	exit 0 ;;
+    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+	echo hppa1.1-hp-osf
+	exit 0 ;;
+    hp8??:OSF1:*:*)
+	echo hppa1.0-hp-osf
+	exit 0 ;;
+    i*86:OSF1:*:*)
+	if [ -x /usr/sbin/sysversion ] ; then
+	    echo ${UNAME_MACHINE}-unknown-osf1mk
+	else
+	    echo ${UNAME_MACHINE}-unknown-osf1
+	fi
+	exit 0 ;;
+    parisc*:Lites*:*:*)
+	echo hppa1.1-hp-lites
+	exit 0 ;;
+    hppa*:OpenBSD:*:*)
+	echo hppa-unknown-openbsd
+	exit 0 ;;
+    C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+	echo c1-convex-bsd
+        exit 0 ;;
+    C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+	if getsysinfo -f scalar_acc
+	then echo c32-convex-bsd
+	else echo c2-convex-bsd
+	fi
+        exit 0 ;;
+    C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+	echo c34-convex-bsd
+        exit 0 ;;
+    C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+	echo c38-convex-bsd
+        exit 0 ;;
+    C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+	echo c4-convex-bsd
+        exit 0 ;;
+    CRAY*X-MP:*:*:*)
+	echo xmp-cray-unicos
+        exit 0 ;;
+    CRAY*Y-MP:*:*:*)
+	echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit 0 ;;
+    CRAY*[A-Z]90:*:*:*)
+	echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+	| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
+	      -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
+	      -e 's/\.[^.]*$/.X/'
+	exit 0 ;;
+    CRAY*TS:*:*:*)
+	echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit 0 ;;
+    CRAY*T3D:*:*:*)
+	echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit 0 ;;
+    CRAY*T3E:*:*:*)
+	echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit 0 ;;
+    CRAY*SV1:*:*:*)
+	echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit 0 ;;
+    CRAY-2:*:*:*)
+	echo cray2-cray-unicos
+        exit 0 ;;
+    F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
+	FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+        FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+        echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+        exit 0 ;;
+    hp300:OpenBSD:*:*)
+	echo m68k-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+	echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+	exit 0 ;;
+    sparc*:BSD/OS:*:*)
+	echo sparc-unknown-bsdi${UNAME_RELEASE}
+	exit 0 ;;
+    *:BSD/OS:*:*)
+	echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+	exit 0 ;;
+    *:FreeBSD:*:*)
+	echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+	exit 0 ;;
+    *:OpenBSD:*:*)
+	echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+	exit 0 ;;
+    i*:CYGWIN*:*)
+	echo ${UNAME_MACHINE}-pc-cygwin
+	exit 0 ;;
+    i*:MINGW*:*)
+	echo ${UNAME_MACHINE}-pc-mingw32
+	exit 0 ;;
+    i*:PW*:*)
+	echo ${UNAME_MACHINE}-pc-pw32
+	exit 0 ;;
+    i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
+	# How do we know it's Interix rather than the generic POSIX subsystem?
+	# It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
+	# UNAME_MACHINE based on the output of uname instead of i386?
+	echo i386-pc-interix
+	exit 0 ;;
+    i*:UWIN*:*)
+	echo ${UNAME_MACHINE}-pc-uwin
+	exit 0 ;;
+    p*:CYGWIN*:*)
+	echo powerpcle-unknown-cygwin
+	exit 0 ;;
+    prep*:SunOS:5.*:*)
+	echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit 0 ;;
+    *:GNU:*:*)
+	echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+	exit 0 ;;
+    i*86:Minix:*:*)
+	echo ${UNAME_MACHINE}-pc-minix
+	exit 0 ;;
+    arm*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit 0 ;;
+    ia64:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux
+	exit 0 ;;
+    m68*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit 0 ;;
+    mips:Linux:*:*)
+	case `sed -n '/^byte/s/^.*: \(.*\) endian/\1/p' < /proc/cpuinfo` in
+	  big)    echo mips-unknown-linux-gnu && exit 0 ;;
+	  little) echo mipsel-unknown-linux-gnu && exit 0 ;;
+	esac
+	;;
+    ppc:Linux:*:*)
+	echo powerpc-unknown-linux-gnu
+	exit 0 ;;
+    ppc64:Linux:*:*)
+	echo powerpc64-unknown-linux-gnu
+	exit 0 ;;
+    alpha:Linux:*:*)
+	case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
+	  EV5)   UNAME_MACHINE=alphaev5 ;;
+	  EV56)  UNAME_MACHINE=alphaev56 ;;
+	  PCA56) UNAME_MACHINE=alphapca56 ;;
+	  PCA57) UNAME_MACHINE=alphapca56 ;;
+	  EV6)   UNAME_MACHINE=alphaev6 ;;
+	  EV67)  UNAME_MACHINE=alphaev67 ;;
+	  EV68*) UNAME_MACHINE=alphaev68 ;;
+        esac
+	objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
+	if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
+	echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
+	exit 0 ;;
+    parisc:Linux:*:* | hppa:Linux:*:*)
+	# Look for CPU level
+	case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
+	  PA7*) echo hppa1.1-unknown-linux-gnu ;;
+	  PA8*) echo hppa2.0-unknown-linux-gnu ;;
+	  *)    echo hppa-unknown-linux-gnu ;;
+	esac
+	exit 0 ;;
+    parisc64:Linux:*:* | hppa64:Linux:*:*)
+	echo hppa64-unknown-linux-gnu
+	exit 0 ;;
+    s390:Linux:*:* | s390x:Linux:*:*)
+	echo ${UNAME_MACHINE}-ibm-linux
+	exit 0 ;;
+    sh*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit 0 ;;
+    sparc:Linux:*:* | sparc64:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit 0 ;;
+    x86_64:Linux:*:*)
+	echo x86_64-unknown-linux-gnu
+	exit 0 ;;
+    i*86:Linux:*:*)
+	# The BFD linker knows what the default object file format is, so
+	# first see if it will tell us. cd to the root directory to prevent
+	# problems with other programs or directories called `ld' in the path.
+	ld_supported_targets=`cd /; ld --help 2>&1 \
+			 | sed -ne '/supported targets:/!d
+				    s/[ 	][ 	]*/ /g
+				    s/.*supported targets: *//
+				    s/ .*//
+				    p'`
+        case "$ld_supported_targets" in
+	  elf32-i386)
+		TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
+		;;
+	  a.out-i386-linux)
+		echo "${UNAME_MACHINE}-pc-linux-gnuaout"
+		exit 0 ;;		
+	  coff-i386)
+		echo "${UNAME_MACHINE}-pc-linux-gnucoff"
+		exit 0 ;;
+	  "")
+		# Either a pre-BFD a.out linker (linux-gnuoldld) or
+		# one that does not give us useful --help.
+		echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
+		exit 0 ;;
+	esac
+	# Determine whether the default compiler is a.out or elf
+	eval $set_cc_for_build
+	cat >$dummy.c <<EOF
+#include <features.h>
+#ifdef __cplusplus
+#include <stdio.h>  /* for printf() prototype */
+	int main (int argc, char *argv[]) {
+#else
+	int main (argc, argv) int argc; char *argv[]; {
+#endif
+#ifdef __ELF__
+# ifdef __GLIBC__
+#  if __GLIBC__ >= 2
+    printf ("%s-pc-linux-gnu\n", argv[1]);
+#  else
+    printf ("%s-pc-linux-gnulibc1\n", argv[1]);
+#  endif
+# else
+   printf ("%s-pc-linux-gnulibc1\n", argv[1]);
+# endif
+#else
+  printf ("%s-pc-linux-gnuaout\n", argv[1]);
+#endif
+  return 0;
+}
+EOF
+	$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0
+	rm -f $dummy.c $dummy
+	test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0
+	;;
+    i*86:DYNIX/ptx:4*:*)
+	# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
+	# earlier versions are messed up and put the nodename in both
+	# sysname and nodename.
+	echo i386-sequent-sysv4
+	exit 0 ;;
+    i*86:UNIX_SV:4.2MP:2.*)
+        # Unixware is an offshoot of SVR4, but it has its own version
+        # number series starting with 2...
+        # I am not positive that other SVR4 systems won't match this,
+	# I just have to hope.  -- rms.
+        # Use sysv4.2uw... so that sysv4* matches it.
+	echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+	exit 0 ;;
+    i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
+	UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
+	if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+		echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
+	else
+		echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
+	fi
+	exit 0 ;;
+    i*86:*:5:[78]*)
+	case `/bin/uname -X | grep "^Machine"` in
+	    *486*)	     UNAME_MACHINE=i486 ;;
+	    *Pentium)	     UNAME_MACHINE=i586 ;;
+	    *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
+	esac
+	echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
+	exit 0 ;;
+    i*86:*:3.2:*)
+	if test -f /usr/options/cb.name; then
+		UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
+		echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
+	elif /bin/uname -X 2>/dev/null >/dev/null ; then
+		UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`
+		(/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
+		(/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
+			&& UNAME_MACHINE=i586
+		(/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \
+			&& UNAME_MACHINE=i686
+		(/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \
+			&& UNAME_MACHINE=i686
+		echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
+	else
+		echo ${UNAME_MACHINE}-pc-sysv32
+	fi
+	exit 0 ;;
+    i*86:*DOS:*:*)
+	echo ${UNAME_MACHINE}-pc-msdosdjgpp
+	exit 0 ;;
+    pc:*:*:*)
+	# Left here for compatibility:
+        # uname -m prints for DJGPP always 'pc', but it prints nothing about
+        # the processor, so we play safe by assuming i386.
+	echo i386-pc-msdosdjgpp
+        exit 0 ;;
+    Intel:Mach:3*:*)
+	echo i386-pc-mach3
+	exit 0 ;;
+    paragon:*:*:*)
+	echo i860-intel-osf1
+	exit 0 ;;
+    i860:*:4.*:*) # i860-SVR4
+	if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
+	  echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+	else # Add other i860-SVR4 vendors below as they are discovered.
+	  echo i860-unknown-sysv${UNAME_RELEASE}  # Unknown i860-SVR4
+	fi
+	exit 0 ;;
+    mini*:CTIX:SYS*5:*)
+	# "miniframe"
+	echo m68010-convergent-sysv
+	exit 0 ;;
+    M68*:*:R3V[567]*:*)
+	test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
+    3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0)
+	OS_REL=''
+	test -r /etc/.relid \
+	&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+	  && echo i486-ncr-sysv4.3${OS_REL} && exit 0
+	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+	  && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;;
+    3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+        /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+          && echo i486-ncr-sysv4 && exit 0 ;;
+    m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
+	echo m68k-unknown-lynxos${UNAME_RELEASE}
+	exit 0 ;;
+    mc68030:UNIX_System_V:4.*:*)
+	echo m68k-atari-sysv4
+	exit 0 ;;
+    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
+	echo i386-unknown-lynxos${UNAME_RELEASE}
+	exit 0 ;;
+    TSUNAMI:LynxOS:2.*:*)
+	echo sparc-unknown-lynxos${UNAME_RELEASE}
+	exit 0 ;;
+    rs6000:LynxOS:2.*:*)
+	echo rs6000-unknown-lynxos${UNAME_RELEASE}
+	exit 0 ;;
+    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
+	echo powerpc-unknown-lynxos${UNAME_RELEASE}
+	exit 0 ;;
+    SM[BE]S:UNIX_SV:*:*)
+	echo mips-dde-sysv${UNAME_RELEASE}
+	exit 0 ;;
+    RM*:ReliantUNIX-*:*:*)
+	echo mips-sni-sysv4
+	exit 0 ;;
+    RM*:SINIX-*:*:*)
+	echo mips-sni-sysv4
+	exit 0 ;;
+    *:SINIX-*:*:*)
+	if uname -p 2>/dev/null >/dev/null ; then
+		UNAME_MACHINE=`(uname -p) 2>/dev/null`
+		echo ${UNAME_MACHINE}-sni-sysv4
+	else
+		echo ns32k-sni-sysv
+	fi
+	exit 0 ;;
+    PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+                      # says <Richard.M.Bartel at ccMail.Census.GOV>
+        echo i586-unisys-sysv4
+        exit 0 ;;
+    *:UNIX_System_V:4*:FTX*)
+	# From Gerald Hewes <hewes at openmarket.com>.
+	# How about differentiating between stratus architectures? -djm
+	echo hppa1.1-stratus-sysv4
+	exit 0 ;;
+    *:*:*:FTX*)
+	# From seanf at swdc.stratus.com.
+	echo i860-stratus-sysv4
+	exit 0 ;;
+    *:VOS:*:*)
+	# From Paul.Green at stratus.com.
+	echo hppa1.1-stratus-vos
+	exit 0 ;;
+    mc68*:A/UX:*:*)
+	echo m68k-apple-aux${UNAME_RELEASE}
+	exit 0 ;;
+    news*:NEWS-OS:6*:*)
+	echo mips-sony-newsos6
+	exit 0 ;;
+    R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
+	if [ -d /usr/nec ]; then
+	        echo mips-nec-sysv${UNAME_RELEASE}
+	else
+	        echo mips-unknown-sysv${UNAME_RELEASE}
+	fi
+        exit 0 ;;
+    BeBox:BeOS:*:*)	# BeOS running on hardware made by Be, PPC only.
+	echo powerpc-be-beos
+	exit 0 ;;
+    BeMac:BeOS:*:*)	# BeOS running on Mac or Mac clone, PPC only.
+	echo powerpc-apple-beos
+	exit 0 ;;
+    BePC:BeOS:*:*)	# BeOS running on Intel PC compatible.
+	echo i586-pc-beos
+	exit 0 ;;
+    SX-4:SUPER-UX:*:*)
+	echo sx4-nec-superux${UNAME_RELEASE}
+	exit 0 ;;
+    SX-5:SUPER-UX:*:*)
+	echo sx5-nec-superux${UNAME_RELEASE}
+	exit 0 ;;
+    Power*:Rhapsody:*:*)
+	echo powerpc-apple-rhapsody${UNAME_RELEASE}
+	exit 0 ;;
+    *:Rhapsody:*:*)
+	echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+	exit 0 ;;
+    *:Darwin:*:*)
+	echo `uname -p`-apple-darwin${UNAME_RELEASE}
+	exit 0 ;;
+    *:procnto*:*:* | *:QNX:[0123456789]*:*)
+	if test "${UNAME_MACHINE}" = "x86pc"; then
+		UNAME_MACHINE=pc
+	fi
+	echo `uname -p`-${UNAME_MACHINE}-nto-qnx
+	exit 0 ;;
+    *:QNX:*:4*)
+	echo i386-pc-qnx
+	exit 0 ;;
+    NSR-[KW]:NONSTOP_KERNEL:*:*)
+	echo nsr-tandem-nsk${UNAME_RELEASE}
+	exit 0 ;;
+    *:NonStop-UX:*:*)
+	echo mips-compaq-nonstopux
+	exit 0 ;;
+    BS2000:POSIX*:*:*)
+	echo bs2000-siemens-sysv
+	exit 0 ;;
+    DS/*:UNIX_System_V:*:*)
+	echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+	exit 0 ;;
+    *:Plan9:*:*)
+	# "uname -m" is not consistent, so use $cputype instead. 386
+	# is converted to i386 for consistency with other x86
+	# operating systems.
+	if test "$cputype" = "386"; then
+	    UNAME_MACHINE=i386
+	else
+	    UNAME_MACHINE="$cputype"
+	fi
+	echo ${UNAME_MACHINE}-unknown-plan9
+	exit 0 ;;
+    i*86:OS/2:*:*)
+	# If we were able to find `uname', then EMX Unix compatibility
+	# is probably installed.
+	echo ${UNAME_MACHINE}-pc-os2-emx
+	exit 0 ;;
+    *:TOPS-10:*:*)
+	echo pdp10-unknown-tops10
+	exit 0 ;;
+    *:TENEX:*:*)
+	echo pdp10-unknown-tenex
+	exit 0 ;;
+    KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
+	echo pdp10-dec-tops20
+	exit 0 ;;
+    XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
+	echo pdp10-xkl-tops20
+	exit 0 ;;
+    *:TOPS-20:*:*)
+	echo pdp10-unknown-tops20
+	exit 0 ;;
+    *:ITS:*:*)
+	echo pdp10-unknown-its
+	exit 0 ;;
+    i*86:XTS-300:*:STOP)
+	echo ${UNAME_MACHINE}-unknown-stop
+	exit 0 ;;
+    i*86:atheos:*:*)
+	echo ${UNAME_MACHINE}-unknown-atheos
+	exit 0 ;;
+esac
+
+#echo '(No uname command or uname output not recognized.)' 1>&2
+#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
+
+eval $set_cc_for_build
+cat >$dummy.c <<EOF
+#ifdef _SEQUENT_
+# include <sys/types.h>
+# include <sys/utsname.h>
+#endif
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
+     I don't know....  */
+  printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include <sys/param.h>
+  printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+          "4"
+#else
+	  ""
+#endif
+         ); exit (0);
+#endif
+#endif
+
+#if defined (__arm) && defined (__acorn) && defined (__unix)
+  printf ("arm-acorn-riscix"); exit (0);
+#endif
+
+#if defined (hp300) && !defined (hpux)
+  printf ("m68k-hp-bsd\n"); exit (0);
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+  int version;
+  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+  if (version < 4)
+    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+  else
+    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
+  exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+  printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+  printf ("ns32k-encore-mach\n"); exit (0);
+#else
+  printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+  printf ("i386-pc-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+  printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+  printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+    struct utsname un;
+
+    uname(&un);
+
+    if (strncmp(un.version, "V2", 2) == 0) {
+	printf ("i386-sequent-ptx2\n"); exit (0);
+    }
+    if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+	printf ("i386-sequent-ptx1\n"); exit (0);
+    }
+    printf ("i386-sequent-ptx\n"); exit (0);
+
+#endif
+
+#if defined (vax)
+# if !defined (ultrix)
+#  include <sys/param.h>
+#  if defined (BSD)
+#   if BSD == 43
+      printf ("vax-dec-bsd4.3\n"); exit (0);
+#   else
+#    if BSD == 199006
+      printf ("vax-dec-bsd4.3reno\n"); exit (0);
+#    else
+      printf ("vax-dec-bsd\n"); exit (0);
+#    endif
+#   endif
+#  else
+    printf ("vax-dec-bsd\n"); exit (0);
+#  endif
+# else
+    printf ("vax-dec-ultrix\n"); exit (0);
+# endif
+#endif
+
+#if defined (alliant) && defined (i860)
+  printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+  exit (1);
+}
+EOF
+
+$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm -f $dummy.c $dummy && exit 0
+rm -f $dummy.c $dummy
+
+# Apollos put the system type in the environment.
+
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; }
+
+# Convex versions that predate uname can use getsysinfo(1)
+
+if [ -x /usr/convex/getsysinfo ]
+then
+    case `getsysinfo -f cpu_type` in
+    c1*)
+	echo c1-convex-bsd
+	exit 0 ;;
+    c2*)
+	if getsysinfo -f scalar_acc
+	then echo c32-convex-bsd
+	else echo c2-convex-bsd
+	fi
+	exit 0 ;;
+    c34*)
+	echo c34-convex-bsd
+	exit 0 ;;
+    c38*)
+	echo c38-convex-bsd
+	exit 0 ;;
+    c4*)
+	echo c4-convex-bsd
+	exit 0 ;;
+    esac
+fi
+
+cat >&2 <<EOF
+$0: unable to guess system type
+
+This script, last modified $timestamp, has failed to recognize
+the operating system you are using. It is advised that you
+download the most up to date version of the config scripts from
+
+    ftp://ftp.gnu.org/pub/gnu/config/
+
+If the version you run ($0) is already up to date, please
+send the following data and any information you think might be
+pertinent to <config-patches at gnu.org> in order to provide the needed
+information to handle your system.
+
+config.guess timestamp = $timestamp
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X     = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo               = `(hostinfo) 2>/dev/null`
+/bin/universe          = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch              = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = ${UNAME_MACHINE}
+UNAME_RELEASE = ${UNAME_RELEASE}
+UNAME_SYSTEM  = ${UNAME_SYSTEM}
+UNAME_VERSION = ${UNAME_VERSION}
+EOF
+
+exit 1
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:


Property changes on: experimental/j/Elphel333/rtp/daemon/rtp/config.guess
___________________________________________________________________
Name: svn:executable
   + 

Added: experimental/j/Elphel333/rtp/daemon/rtp/config.h.in
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/config.h.in	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/config.h.in	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,174 @@
+/* config.h.in.  Generated from configure.in by autoheader.  */
+/*
+ * Define this if you have a /dev/urandom which can supply good random numbers.
+ */
+#undef HAVE_DEV_URANDOM
+
+/*
+ * Define this if you want IPv6 support.
+ */
+#undef HAVE_IPv6
+
+/*
+ * V6 structures that host may or may not be present.
+ */
+#undef HAVE_ST_ADDRINFO
+#undef HAVE_GETIPNODEBYNAME
+#undef HAVE_SIN6_LEN
+
+/*
+ * Define these if your C library is missing some functions...
+ */
+#undef NEED_VSNPRINTF
+#undef NEED_INET_PTON
+#undef NEED_INET_NTOP
+
+/*
+ * If you don't have these types in <inttypes.h>, #define these to be
+ * the types you do have.
+ */
+#undef int8_t
+#undef int16_t
+#undef int32_t
+#undef int64_t
+#undef uint8_t
+#undef uint16_t
+#undef uint32_t
+
+/*
+ * Debugging:
+ * DEBUG: general debugging
+ * DEBUG_MEM: debug memory allocation
+ */
+#undef DEBUG
+#undef DEBUG_MEM
+
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#undef HAVE_DLFCN_H
+
+/* Define to 1 if you have the `inet_aton' function. */
+#undef HAVE_INET_ATON
+
+/* Define to 1 if you have the `inet_ntop' function. */
+#undef HAVE_INET_NTOP
+
+/* Define to 1 if you have the `inet_pton' function. */
+#undef HAVE_INET_PTON
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* Define to 1 if you have the <netinet6/in6.h> header file. */
+#undef HAVE_NETINET6_IN6_H
+
+/* Define to 1 if you have the <netinet/ip6.h> header file. */
+#undef HAVE_NETINET_IP6_H
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define to 1 if you have the <stropts.h> header file. */
+#undef HAVE_STROPTS_H
+
+/* Define to 1 if you have the <sys/filio.h> header file. */
+#undef HAVE_SYS_FILIO_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#undef HAVE_SYS_TIME_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
+#undef HAVE_SYS_WAIT_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define to 1 if you have the `vsnprintf' function. */
+#undef HAVE_VSNPRINTF
+
+/* Name of package */
+#undef PACKAGE
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
+#undef TIME_WITH_SYS_TIME
+
+/* Version number of package */
+#undef VERSION
+
+/* Define to 1 if your processor stores words with the most significant byte
+   first (like Motorola and SPARC, unlike Intel and VAX). */
+#undef WORDS_BIGENDIAN
+
+/* Define to 1 if type `char' is unsigned and you are not using gcc.  */
+#ifndef __CHAR_UNSIGNED__
+# undef __CHAR_UNSIGNED__
+#endif
+
+/* Define to empty if `const' does not conform to ANSI C. */
+#undef const
+
+/* Define to `short' if <sys/types.h> does not define. */
+#undef int16_t
+
+/* Define to `long' if <sys/types.h> does not define. */
+#undef int32_t
+
+/* Define to `long long' if <sys/types.h> does not define. */
+#undef int64_t
+
+/* Define to `signed char' if <sys/types.h> does not define. */
+#undef int8_t
+
+/* Define to `unsigned' if <sys/types.h> does not define. */
+#undef size_t
+
+/* Define to `unsigned short' if <sys/types.h> does not define. */
+#undef uint16_t
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+#undef uint32_t
+
+/* Define to `unsigned char' if <sys/types.h> does not define. */
+#undef uint8_t
+
+#ifndef WORDS_BIGENDIAN
+#define WORDS_SMALLENDIAN
+#endif
+
+

Added: experimental/j/Elphel333/rtp/daemon/rtp/config.sub
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/config.sub	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/config.sub	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,1411 @@
+#! /bin/sh
+# Configuration validation subroutine script.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+#   Free Software Foundation, Inc.
+
+timestamp='2001-09-07'
+
+# This file is (in principle) common to ALL GNU software.
+# The presence of a machine in this file suggests that SOME GNU software
+# can handle that machine.  It does not imply ALL GNU software can.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Please send patches to <config-patches at gnu.org>.
+#
+# Configuration subroutine to validate and canonicalize a configuration type.
+# Supply the specified configuration type as an argument.
+# If it is invalid, we print an error message on stderr and exit with code 1.
+# Otherwise, we print the canonical config type on stdout and succeed.
+
+# This file is supposed to be the same for all GNU packages
+# and recognize all the CPU types, system types and aliases
+# that are meaningful with *any* GNU software.
+# Each package is responsible for reporting which valid configurations
+# it does not support.  The user should be able to distinguish
+# a failure to support a valid configuration from a meaningless
+# configuration.
+
+# The goal of this file is to map all the various variations of a given
+# machine specification into a single specification in the form:
+#	CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or in some cases, the newer four-part form:
+#	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# It is wrong to echo any other type of specification.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS
+       $0 [OPTION] ALIAS
+
+Canonicalize a configuration name.
+
+Operation modes:
+  -h, --help         print this help, then exit
+  -t, --time-stamp   print date of last modification, then exit
+  -v, --version      print version number, then exit
+
+Report bugs and patches to <config-patches at gnu.org>."
+
+version="\
+GNU config.sub ($timestamp)
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+  case $1 in
+    --time-stamp | --time* | -t )
+       echo "$timestamp" ; exit 0 ;;
+    --version | -v )
+       echo "$version" ; exit 0 ;;
+    --help | --h* | -h )
+       echo "$usage"; exit 0 ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )	# Use stdin as input.
+       break ;;
+    -* )
+       echo "$me: invalid option $1$help"
+       exit 1 ;;
+
+    *local*)
+       # First pass through any local machine types.
+       echo $1
+       exit 0;;
+
+    * )
+       break ;;
+  esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+    exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+    exit 1;;
+esac
+
+# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
+# Here we must recognize all the valid KERNEL-OS combinations.
+maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+case $maybe_os in
+  nto-qnx* | linux-gnu* | storm-chaos* | os2-emx* | windows32-*)
+    os=-$maybe_os
+    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+    ;;
+  *)
+    basic_machine=`echo $1 | sed 's/-[^-]*$//'`
+    if [ $basic_machine != $1 ]
+    then os=`echo $1 | sed 's/.*-/-/'`
+    else os=; fi
+    ;;
+esac
+
+### Let's recognize common machines as not being operating systems so
+### that things like config.sub decstation-3100 work.  We also
+### recognize some manufacturers as not being operating systems, so we
+### can provide default operating systems below.
+case $os in
+	-sun*os*)
+		# Prevent following clause from handling this invalid input.
+		;;
+	-dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
+	-att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
+	-unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
+	-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
+	-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
+	-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
+	-apple | -axis)
+		os=
+		basic_machine=$1
+		;;
+	-sim | -cisco | -oki | -wec | -winbond)
+		os=
+		basic_machine=$1
+		;;
+	-scout)
+		;;
+	-wrs)
+		os=-vxworks
+		basic_machine=$1
+		;;
+	-chorusos*)
+		os=-chorusos
+		basic_machine=$1
+		;;
+ 	-chorusrdb)
+ 		os=-chorusrdb
+		basic_machine=$1
+ 		;;
+	-hiux*)
+		os=-hiuxwe2
+		;;
+	-sco5)
+		os=-sco3.2v5
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-sco4)
+		os=-sco3.2v4
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-sco3.2.[4-9]*)
+		os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-sco3.2v[4-9]*)
+		# Don't forget version if it is 3.2v4 or newer.
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-sco*)
+		os=-sco3.2v2
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-udk*)
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-isc)
+		os=-isc2.2
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-clix*)
+		basic_machine=clipper-intergraph
+		;;
+	-isc*)
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-lynx*)
+		os=-lynxos
+		;;
+	-ptx*)
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
+		;;
+	-windowsnt*)
+		os=`echo $os | sed -e 's/windowsnt/winnt/'`
+		;;
+	-psos*)
+		os=-psos
+		;;
+	-mint | -mint[0-9]*)
+		basic_machine=m68k-atari
+		os=-mint
+		;;
+esac
+
+# Decode aliases for certain CPU-COMPANY combinations.
+case $basic_machine in
+	# Recognize the basic CPU types without company name.
+	# Some are omitted here because they have special meanings below.
+	1750a | 580 \
+	| a29k \
+	| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
+	| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
+	| c4x | clipper \
+	| d10v | d30v | dsp16xx \
+	| fr30 \
+	| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+	| i370 | i860 | i960 | ia64 \
+	| m32r | m68000 | m68k | m88k | mcore \
+	| mips16 | mips64 | mips64el | mips64orion | mips64orionel \
+	| mips64vr4100 | mips64vr4100el | mips64vr4300 \
+	| mips64vr4300el | mips64vr5000 | mips64vr5000el \
+	| mipsbe | mipseb | mipsel | mipsle | mipstx39 | mipstx39el \
+	| mipsisa32 \
+	| mn10200 | mn10300 \
+	| ns16k | ns32k \
+	| openrisc \
+	| pdp10 | pdp11 | pj | pjl \
+	| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
+	| pyramid \
+	| s390 | s390x \
+	| sh | sh[34] | sh[34]eb | shbe | shle \
+	| sparc | sparc64 | sparclet | sparclite | sparcv9 | sparcv9b \
+	| stormy16 | strongarm \
+	| tahoe | thumb | tic80 | tron \
+	| v850 \
+	| we32k \
+	| x86 | xscale \
+	| z8k)
+		basic_machine=$basic_machine-unknown
+		;;
+	m6811 | m68hc11 | m6812 | m68hc12)
+		# Motorola 68HC11/12.
+		basic_machine=$basic_machine-unknown
+		os=-none
+		;;
+	m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
+		;;
+
+	# We use `pc' rather than `unknown'
+	# because (1) that's what they normally are, and
+	# (2) the word "unknown" tends to confuse beginning users.
+	i*86 | x86_64)
+	  basic_machine=$basic_machine-pc
+	  ;;
+	# Object if more than one company name word.
+	*-*-*)
+		echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+		exit 1
+		;;
+	# Recognize the basic CPU types with company name.
+	580-* \
+	| a29k-* \
+	| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
+	| alphapca5[67]-* | arc-* \
+	| arm-*  | armbe-* | armle-* | armv*-* \
+	| bs2000-* \
+	| c[123]* | c30-* | [cjt]90-* | c54x-* \
+	| clipper-* | cray2-* | cydra-* \
+	| d10v-* | d30v-* \
+	| elxsi-* \
+	| f30[01]-* | f700-* | fr30-* | fx80-* \
+	| h8300-* | h8500-* \
+	| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+	| i*86-* | i860-* | i960-* | ia64-* \
+	| m32r-* \
+	| m68000-* | m680[01234]0-* | m68360-* | m683?2-* | m68k-* \
+	| m88110-* | m88k-* | mcore-* \
+	| mips-* | mips16-* | mips64-* | mips64el-* | mips64orion-* \
+	| mips64orionel-* | mips64vr4100-* | mips64vr4100el-* \
+	| mips64vr4300-* | mips64vr4300el-* | mipsbe-* | mipseb-* \
+	| mipsle-* | mipsel-* | mipstx39-* | mipstx39el-* \
+	| none-* | np1-* | ns16k-* | ns32k-* \
+	| orion-* \
+	| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
+	| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
+	| pyramid-* \
+	| romp-* | rs6000-* \
+	| s390-* | s390x-* \
+	| sh-* | sh[34]-* | sh[34]eb-* | shbe-* | shle-* \
+	| sparc-* | sparc64-* | sparc86x-* | sparclite-* \
+	| sparcv9-* | sparcv9b-* | stormy16-* | strongarm-* | sv1-* \
+	| t3e-* | tahoe-* | thumb-* | tic30-* | tic54x-* | tic80-* | tron-* \
+	| v850-* | vax-* \
+	| we32k-* \
+	| x86-* | x86_64-* | xmp-* | xps100-* | xscale-* \
+	| ymp-* \
+	| z8k-*)
+		;;
+	# Recognize the various machine names and aliases which stand
+	# for a CPU type and a company and sometimes even an OS.
+	386bsd)
+		basic_machine=i386-unknown
+		os=-bsd
+		;;
+	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
+		basic_machine=m68000-att
+		;;
+	3b*)
+		basic_machine=we32k-att
+		;;
+	a29khif)
+		basic_machine=a29k-amd
+		os=-udi
+		;;
+	adobe68k)
+		basic_machine=m68010-adobe
+		os=-scout
+		;;
+	alliant | fx80)
+		basic_machine=fx80-alliant
+		;;
+	altos | altos3068)
+		basic_machine=m68k-altos
+		;;
+	am29k)
+		basic_machine=a29k-none
+		os=-bsd
+		;;
+	amdahl)
+		basic_machine=580-amdahl
+		os=-sysv
+		;;
+	amiga | amiga-*)
+		basic_machine=m68k-unknown
+		;;
+	amigaos | amigados)
+		basic_machine=m68k-unknown
+		os=-amigaos
+		;;
+	amigaunix | amix)
+		basic_machine=m68k-unknown
+		os=-sysv4
+		;;
+	apollo68)
+		basic_machine=m68k-apollo
+		os=-sysv
+		;;
+	apollo68bsd)
+		basic_machine=m68k-apollo
+		os=-bsd
+		;;
+	aux)
+		basic_machine=m68k-apple
+		os=-aux
+		;;
+	balance)
+		basic_machine=ns32k-sequent
+		os=-dynix
+		;;
+	convex-c1)
+		basic_machine=c1-convex
+		os=-bsd
+		;;
+	convex-c2)
+		basic_machine=c2-convex
+		os=-bsd
+		;;
+	convex-c32)
+		basic_machine=c32-convex
+		os=-bsd
+		;;
+	convex-c34)
+		basic_machine=c34-convex
+		os=-bsd
+		;;
+	convex-c38)
+		basic_machine=c38-convex
+		os=-bsd
+		;;
+	cray | ymp)
+		basic_machine=ymp-cray
+		os=-unicos
+		;;
+	cray2)
+		basic_machine=cray2-cray
+		os=-unicos
+		;;
+	[cjt]90)
+		basic_machine=${basic_machine}-cray
+		os=-unicos
+		;;
+	crds | unos)
+		basic_machine=m68k-crds
+		;;
+	cris | cris-* | etrax*)
+		basic_machine=cris-axis
+		;;
+	da30 | da30-*)
+		basic_machine=m68k-da30
+		;;
+	decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
+		basic_machine=mips-dec
+		;;
+	delta | 3300 | motorola-3300 | motorola-delta \
+	      | 3300-motorola | delta-motorola)
+		basic_machine=m68k-motorola
+		;;
+	delta88)
+		basic_machine=m88k-motorola
+		os=-sysv3
+		;;
+	dpx20 | dpx20-*)
+		basic_machine=rs6000-bull
+		os=-bosx
+		;;
+	dpx2* | dpx2*-bull)
+		basic_machine=m68k-bull
+		os=-sysv3
+		;;
+	ebmon29k)
+		basic_machine=a29k-amd
+		os=-ebmon
+		;;
+	elxsi)
+		basic_machine=elxsi-elxsi
+		os=-bsd
+		;;
+	encore | umax | mmax)
+		basic_machine=ns32k-encore
+		;;
+	es1800 | OSE68k | ose68k | ose | OSE)
+		basic_machine=m68k-ericsson
+		os=-ose
+		;;
+	fx2800)
+		basic_machine=i860-alliant
+		;;
+	genix)
+		basic_machine=ns32k-ns
+		;;
+	gmicro)
+		basic_machine=tron-gmicro
+		os=-sysv
+		;;
+	go32)
+		basic_machine=i386-pc
+		os=-go32
+		;;
+	h3050r* | hiux*)
+		basic_machine=hppa1.1-hitachi
+		os=-hiuxwe2
+		;;
+	h8300hms)
+		basic_machine=h8300-hitachi
+		os=-hms
+		;;
+	h8300xray)
+		basic_machine=h8300-hitachi
+		os=-xray
+		;;
+	h8500hms)
+		basic_machine=h8500-hitachi
+		os=-hms
+		;;
+	harris)
+		basic_machine=m88k-harris
+		os=-sysv3
+		;;
+	hp300-*)
+		basic_machine=m68k-hp
+		;;
+	hp300bsd)
+		basic_machine=m68k-hp
+		os=-bsd
+		;;
+	hp300hpux)
+		basic_machine=m68k-hp
+		os=-hpux
+		;;
+	hp3k9[0-9][0-9] | hp9[0-9][0-9])
+		basic_machine=hppa1.0-hp
+		;;
+	hp9k2[0-9][0-9] | hp9k31[0-9])
+		basic_machine=m68000-hp
+		;;
+	hp9k3[2-9][0-9])
+		basic_machine=m68k-hp
+		;;
+	hp9k6[0-9][0-9] | hp6[0-9][0-9])
+		basic_machine=hppa1.0-hp
+		;;
+	hp9k7[0-79][0-9] | hp7[0-79][0-9])
+		basic_machine=hppa1.1-hp
+		;;
+	hp9k78[0-9] | hp78[0-9])
+		# FIXME: really hppa2.0-hp
+		basic_machine=hppa1.1-hp
+		;;
+	hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
+		# FIXME: really hppa2.0-hp
+		basic_machine=hppa1.1-hp
+		;;
+	hp9k8[0-9][13679] | hp8[0-9][13679])
+		basic_machine=hppa1.1-hp
+		;;
+	hp9k8[0-9][0-9] | hp8[0-9][0-9])
+		basic_machine=hppa1.0-hp
+		;;
+	hppa-next)
+		os=-nextstep3
+		;;
+	hppaosf)
+		basic_machine=hppa1.1-hp
+		os=-osf
+		;;
+	hppro)
+		basic_machine=hppa1.1-hp
+		os=-proelf
+		;;
+	i370-ibm* | ibm*)
+		basic_machine=i370-ibm
+		;;
+# I'm not sure what "Sysv32" means.  Should this be sysv3.2?
+	i*86v32)
+		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+		os=-sysv32
+		;;
+	i*86v4*)
+		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+		os=-sysv4
+		;;
+	i*86v)
+		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+		os=-sysv
+		;;
+	i*86sol2)
+		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+		os=-solaris2
+		;;
+	i386mach)
+		basic_machine=i386-mach
+		os=-mach
+		;;
+	i386-vsta | vsta)
+		basic_machine=i386-unknown
+		os=-vsta
+		;;
+	iris | iris4d)
+		basic_machine=mips-sgi
+		case $os in
+		    -irix*)
+			;;
+		    *)
+			os=-irix4
+			;;
+		esac
+		;;
+	isi68 | isi)
+		basic_machine=m68k-isi
+		os=-sysv
+		;;
+	m88k-omron*)
+		basic_machine=m88k-omron
+		;;
+	magnum | m3230)
+		basic_machine=mips-mips
+		os=-sysv
+		;;
+	merlin)
+		basic_machine=ns32k-utek
+		os=-sysv
+		;;
+	mingw32)
+		basic_machine=i386-pc
+		os=-mingw32
+		;;
+	miniframe)
+		basic_machine=m68000-convergent
+		;;
+	*mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
+		basic_machine=m68k-atari
+		os=-mint
+		;;
+	mipsel*-linux*)
+		basic_machine=mipsel-unknown
+		os=-linux-gnu
+		;;
+	mips*-linux*)
+		basic_machine=mips-unknown
+		os=-linux-gnu
+		;;
+	mips3*-*)
+		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+		;;
+	mips3*)
+		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+		;;
+	mmix*)
+		basic_machine=mmix-knuth
+		os=-mmixware
+		;;
+	monitor)
+		basic_machine=m68k-rom68k
+		os=-coff
+		;;
+	msdos)
+		basic_machine=i386-pc
+		os=-msdos
+		;;
+	mvs)
+		basic_machine=i370-ibm
+		os=-mvs
+		;;
+	ncr3000)
+		basic_machine=i486-ncr
+		os=-sysv4
+		;;
+	netbsd386)
+		basic_machine=i386-unknown
+		os=-netbsd
+		;;
+	netwinder)
+		basic_machine=armv4l-rebel
+		os=-linux
+		;;
+	news | news700 | news800 | news900)
+		basic_machine=m68k-sony
+		os=-newsos
+		;;
+	news1000)
+		basic_machine=m68030-sony
+		os=-newsos
+		;;
+	news-3600 | risc-news)
+		basic_machine=mips-sony
+		os=-newsos
+		;;
+	necv70)
+		basic_machine=v70-nec
+		os=-sysv
+		;;
+	next | m*-next )
+		basic_machine=m68k-next
+		case $os in
+		    -nextstep* )
+			;;
+		    -ns2*)
+		      os=-nextstep2
+			;;
+		    *)
+		      os=-nextstep3
+			;;
+		esac
+		;;
+	nh3000)
+		basic_machine=m68k-harris
+		os=-cxux
+		;;
+	nh[45]000)
+		basic_machine=m88k-harris
+		os=-cxux
+		;;
+	nindy960)
+		basic_machine=i960-intel
+		os=-nindy
+		;;
+	mon960)
+		basic_machine=i960-intel
+		os=-mon960
+		;;
+	nonstopux)
+		basic_machine=mips-compaq
+		os=-nonstopux
+		;;
+	np1)
+		basic_machine=np1-gould
+		;;
+	nsr-tandem)
+		basic_machine=nsr-tandem
+		;;
+	op50n-* | op60c-*)
+		basic_machine=hppa1.1-oki
+		os=-proelf
+		;;
+	OSE68000 | ose68000)
+		basic_machine=m68000-ericsson
+		os=-ose
+		;;
+	os68k)
+		basic_machine=m68k-none
+		os=-os68k
+		;;
+	pa-hitachi)
+		basic_machine=hppa1.1-hitachi
+		os=-hiuxwe2
+		;;
+	paragon)
+		basic_machine=i860-intel
+		os=-osf
+		;;
+	pbd)
+		basic_machine=sparc-tti
+		;;
+	pbb)
+		basic_machine=m68k-tti
+		;;
+        pc532 | pc532-*)
+		basic_machine=ns32k-pc532
+		;;
+	pentium | p5 | k5 | k6 | nexgen)
+		basic_machine=i586-pc
+		;;
+	pentiumpro | p6 | 6x86 | athlon)
+		basic_machine=i686-pc
+		;;
+	pentiumii | pentium2)
+		basic_machine=i686-pc
+		;;
+	pentium-* | p5-* | k5-* | k6-* | nexgen-*)
+		basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	pentiumpro-* | p6-* | 6x86-* | athlon-*)
+		basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	pentiumii-* | pentium2-*)
+		basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	pn)
+		basic_machine=pn-gould
+		;;
+	power)	basic_machine=power-ibm
+		;;
+	ppc)	basic_machine=powerpc-unknown
+	        ;;
+	ppc-*)	basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	ppcle | powerpclittle | ppc-le | powerpc-little)
+		basic_machine=powerpcle-unknown
+	        ;;
+	ppcle-* | powerpclittle-*)
+		basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	ppc64)	basic_machine=powerpc64-unknown
+	        ;;
+	ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	ppc64le | powerpc64little | ppc64-le | powerpc64-little)
+		basic_machine=powerpc64le-unknown
+	        ;;
+	ppc64le-* | powerpc64little-*)
+		basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	ps2)
+		basic_machine=i386-ibm
+		;;
+	pw32)
+		basic_machine=i586-unknown
+		os=-pw32
+		;;
+	rom68k)
+		basic_machine=m68k-rom68k
+		os=-coff
+		;;
+	rm[46]00)
+		basic_machine=mips-siemens
+		;;
+	rtpc | rtpc-*)
+		basic_machine=romp-ibm
+		;;
+	sa29200)
+		basic_machine=a29k-amd
+		os=-udi
+		;;
+	sequent)
+		basic_machine=i386-sequent
+		;;
+	sh)
+		basic_machine=sh-hitachi
+		os=-hms
+		;;
+	sparclite-wrs)
+		basic_machine=sparclite-wrs
+		os=-vxworks
+		;;
+	sps7)
+		basic_machine=m68k-bull
+		os=-sysv2
+		;;
+	spur)
+		basic_machine=spur-unknown
+		;;
+	st2000)
+		basic_machine=m68k-tandem
+		;;
+	stratus)
+		basic_machine=i860-stratus
+		os=-sysv4
+		;;
+	sun2)
+		basic_machine=m68000-sun
+		;;
+	sun2os3)
+		basic_machine=m68000-sun
+		os=-sunos3
+		;;
+	sun2os4)
+		basic_machine=m68000-sun
+		os=-sunos4
+		;;
+	sun3os3)
+		basic_machine=m68k-sun
+		os=-sunos3
+		;;
+	sun3os4)
+		basic_machine=m68k-sun
+		os=-sunos4
+		;;
+	sun4os3)
+		basic_machine=sparc-sun
+		os=-sunos3
+		;;
+	sun4os4)
+		basic_machine=sparc-sun
+		os=-sunos4
+		;;
+	sun4sol2)
+		basic_machine=sparc-sun
+		os=-solaris2
+		;;
+	sun3 | sun3-*)
+		basic_machine=m68k-sun
+		;;
+	sun4)
+		basic_machine=sparc-sun
+		;;
+	sun386 | sun386i | roadrunner)
+		basic_machine=i386-sun
+		;;
+	sv1)
+		basic_machine=sv1-cray
+		os=-unicos
+		;;
+	symmetry)
+		basic_machine=i386-sequent
+		os=-dynix
+		;;
+	t3e)
+		basic_machine=t3e-cray
+		os=-unicos
+		;;
+	tic54x | c54x*)
+		basic_machine=tic54x-unknown
+		os=-coff
+		;;
+	tx39)
+		basic_machine=mipstx39-unknown
+		;;
+	tx39el)
+		basic_machine=mipstx39el-unknown
+		;;
+	tower | tower-32)
+		basic_machine=m68k-ncr
+		;;
+	udi29k)
+		basic_machine=a29k-amd
+		os=-udi
+		;;
+	ultra3)
+		basic_machine=a29k-nyu
+		os=-sym1
+		;;
+	v810 | necv810)
+		basic_machine=v810-nec
+		os=-none
+		;;
+	vaxv)
+		basic_machine=vax-dec
+		os=-sysv
+		;;
+	vms)
+		basic_machine=vax-dec
+		os=-vms
+		;;
+	vpp*|vx|vx-*)
+               basic_machine=f301-fujitsu
+               ;;
+	vxworks960)
+		basic_machine=i960-wrs
+		os=-vxworks
+		;;
+	vxworks68)
+		basic_machine=m68k-wrs
+		os=-vxworks
+		;;
+	vxworks29k)
+		basic_machine=a29k-wrs
+		os=-vxworks
+		;;
+	w65*)
+		basic_machine=w65-wdc
+		os=-none
+		;;
+	w89k-*)
+		basic_machine=hppa1.1-winbond
+		os=-proelf
+		;;
+	windows32)
+		basic_machine=i386-pc
+		os=-windows32-msvcrt
+		;;
+	xmp)
+		basic_machine=xmp-cray
+		os=-unicos
+		;;
+        xps | xps100)
+		basic_machine=xps100-honeywell
+		;;
+	z8k-*-coff)
+		basic_machine=z8k-unknown
+		os=-sim
+		;;
+	none)
+		basic_machine=none-none
+		os=-none
+		;;
+
+# Here we handle the default manufacturer of certain CPU types.  It is in
+# some cases the only manufacturer, in others, it is the most popular.
+	w89k)
+		basic_machine=hppa1.1-winbond
+		;;
+	op50n)
+		basic_machine=hppa1.1-oki
+		;;
+	op60c)
+		basic_machine=hppa1.1-oki
+		;;
+	mips)
+		if [ x$os = x-linux-gnu ]; then
+			basic_machine=mips-unknown
+		else
+			basic_machine=mips-mips
+		fi
+		;;
+	romp)
+		basic_machine=romp-ibm
+		;;
+	rs6000)
+		basic_machine=rs6000-ibm
+		;;
+	vax)
+		basic_machine=vax-dec
+		;;
+	pdp10)
+		# there are many clones, so DEC is not a safe bet
+		basic_machine=pdp10-unknown
+		;;
+	pdp11)
+		basic_machine=pdp11-dec
+		;;
+	we32k)
+		basic_machine=we32k-att
+		;;
+	sh3 | sh4 | sh3eb | sh4eb)
+		basic_machine=sh-unknown
+		;;
+	sparc | sparcv9 | sparcv9b)
+		basic_machine=sparc-sun
+		;;
+        cydra)
+		basic_machine=cydra-cydrome
+		;;
+	orion)
+		basic_machine=orion-highlevel
+		;;
+	orion105)
+		basic_machine=clipper-highlevel
+		;;
+	mac | mpw | mac-mpw)
+		basic_machine=m68k-apple
+		;;
+	pmac | pmac-mpw)
+		basic_machine=powerpc-apple
+		;;
+	c4x*)
+		basic_machine=c4x-none
+		os=-coff
+		;;
+	*-unknown)
+		# Make sure to match an already-canonicalized machine name.
+		;;
+	*)
+		echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+		exit 1
+		;;
+esac
+
+# Here we canonicalize certain aliases for manufacturers.
+case $basic_machine in
+	*-digital*)
+		basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+		;;
+	*-commodore*)
+		basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+		;;
+	*)
+		;;
+esac
+
+# Decode manufacturer-specific aliases for certain operating systems.
+
+if [ x"$os" != x"" ]
+then
+case $os in
+        # First match some system type aliases
+        # that might get confused with valid system types.
+	# -solaris* is a basic system type, with this one exception.
+	-solaris1 | -solaris1.*)
+		os=`echo $os | sed -e 's|solaris1|sunos4|'`
+		;;
+	-solaris)
+		os=-solaris2
+		;;
+	-svr4*)
+		os=-sysv4
+		;;
+	-unixware*)
+		os=-sysv4.2uw
+		;;
+	-gnu/linux*)
+		os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
+		;;
+	# First accept the basic system types.
+	# The portable systems comes first.
+	# Each alternative MUST END IN A *, to match a version number.
+	# -sysv* is not here because it comes later, after sysvr4.
+	-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
+	      | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
+	      | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
+	      | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+	      | -aos* \
+	      | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+	      | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+	      | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \
+	      | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
+	      | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
+	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+	      | -chorusos* | -chorusrdb* \
+	      | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+	      | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \
+	      | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \
+	      | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+	      | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
+	      | -os2* | -vos*)
+	# Remember, each alternative MUST END IN *, to match a version number.
+		;;
+	-qnx*)
+		case $basic_machine in
+		    x86-* | i*86-*)
+			;;
+		    *)
+			os=-nto$os
+			;;
+		esac
+		;;
+	-nto*)
+		os=-nto-qnx
+		;;
+	-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+	      | -windows* | -osx | -abug | -netware* | -os9* | -beos* \
+	      | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
+		;;
+	-mac*)
+		os=`echo $os | sed -e 's|mac|macos|'`
+		;;
+	-linux*)
+		os=`echo $os | sed -e 's|linux|linux-gnu|'`
+		;;
+	-sunos5*)
+		os=`echo $os | sed -e 's|sunos5|solaris2|'`
+		;;
+	-sunos6*)
+		os=`echo $os | sed -e 's|sunos6|solaris3|'`
+		;;
+	-opened*)
+		os=-openedition
+		;;
+	-wince*)
+		os=-wince
+		;;
+	-osfrose*)
+		os=-osfrose
+		;;
+	-osf*)
+		os=-osf
+		;;
+	-utek*)
+		os=-bsd
+		;;
+	-dynix*)
+		os=-bsd
+		;;
+	-acis*)
+		os=-aos
+		;;
+	-386bsd)
+		os=-bsd
+		;;
+	-ctix* | -uts*)
+		os=-sysv
+		;;
+	-ns2 )
+	        os=-nextstep2
+		;;
+	-nsk*)
+		os=-nsk
+		;;
+	# Preserve the version number of sinix5.
+	-sinix5.*)
+		os=`echo $os | sed -e 's|sinix|sysv|'`
+		;;
+	-sinix*)
+		os=-sysv4
+		;;
+	-triton*)
+		os=-sysv3
+		;;
+	-oss*)
+		os=-sysv3
+		;;
+	-svr4)
+		os=-sysv4
+		;;
+	-svr3)
+		os=-sysv3
+		;;
+	-sysvr4)
+		os=-sysv4
+		;;
+	# This must come after -sysvr4.
+	-sysv*)
+		;;
+	-ose*)
+		os=-ose
+		;;
+	-es1800*)
+		os=-ose
+		;;
+	-xenix)
+		os=-xenix
+		;;
+        -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+	        os=-mint
+		;;
+	-none)
+		;;
+	*)
+		# Get rid of the `-' at the beginning of $os.
+		os=`echo $os | sed 's/[^-]*-//'`
+		echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+		exit 1
+		;;
+esac
+else
+
+# Here we handle the default operating systems that come with various machines.
+# The value should be what the vendor currently ships out the door with their
+# machine or put another way, the most popular os provided with the machine.
+
+# Note that if you're going to try to match "-MANUFACTURER" here (say,
+# "-sun"), then you have to tell the case statement up towards the top
+# that MANUFACTURER isn't an operating system.  Otherwise, code above
+# will signal an error saying that MANUFACTURER isn't an operating
+# system, and we'll never get to this point.
+
+case $basic_machine in
+	*-acorn)
+		os=-riscix1.2
+		;;
+	arm*-rebel)
+		os=-linux
+		;;
+	arm*-semi)
+		os=-aout
+		;;
+	pdp10-*)
+		os=-tops20
+		;;
+        pdp11-*)
+		os=-none
+		;;
+	*-dec | vax-*)
+		os=-ultrix4.2
+		;;
+	m68*-apollo)
+		os=-domain
+		;;
+	i386-sun)
+		os=-sunos4.0.2
+		;;
+	m68000-sun)
+		os=-sunos3
+		# This also exists in the configure program, but was not the
+		# default.
+		# os=-sunos4
+		;;
+	m68*-cisco)
+		os=-aout
+		;;
+	mips*-cisco)
+		os=-elf
+		;;
+	mips*-*)
+		os=-elf
+		;;
+	*-tti)	# must be before sparc entry or we get the wrong os.
+		os=-sysv3
+		;;
+	sparc-* | *-sun)
+		os=-sunos4.1.1
+		;;
+	*-be)
+		os=-beos
+		;;
+	*-ibm)
+		os=-aix
+		;;
+	*-wec)
+		os=-proelf
+		;;
+	*-winbond)
+		os=-proelf
+		;;
+	*-oki)
+		os=-proelf
+		;;
+	*-hp)
+		os=-hpux
+		;;
+	*-hitachi)
+		os=-hiux
+		;;
+	i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
+		os=-sysv
+		;;
+	*-cbm)
+		os=-amigaos
+		;;
+	*-dg)
+		os=-dgux
+		;;
+	*-dolphin)
+		os=-sysv3
+		;;
+	m68k-ccur)
+		os=-rtu
+		;;
+	m88k-omron*)
+		os=-luna
+		;;
+	*-next )
+		os=-nextstep
+		;;
+	*-sequent)
+		os=-ptx
+		;;
+	*-crds)
+		os=-unos
+		;;
+	*-ns)
+		os=-genix
+		;;
+	i370-*)
+		os=-mvs
+		;;
+	*-next)
+		os=-nextstep3
+		;;
+        *-gould)
+		os=-sysv
+		;;
+        *-highlevel)
+		os=-bsd
+		;;
+	*-encore)
+		os=-bsd
+		;;
+        *-sgi)
+		os=-irix
+		;;
+        *-siemens)
+		os=-sysv4
+		;;
+	*-masscomp)
+		os=-rtu
+		;;
+	f30[01]-fujitsu | f700-fujitsu)
+		os=-uxpv
+		;;
+	*-rom68k)
+		os=-coff
+		;;
+	*-*bug)
+		os=-coff
+		;;
+	*-apple)
+		os=-macos
+		;;
+	*-atari*)
+		os=-mint
+		;;
+	*)
+		os=-none
+		;;
+esac
+fi
+
+# Here we handle the case where we know the os, and the CPU type, but not the
+# manufacturer.  We pick the logical manufacturer.
+vendor=unknown
+case $basic_machine in
+	*-unknown)
+		case $os in
+			-riscix*)
+				vendor=acorn
+				;;
+			-sunos*)
+				vendor=sun
+				;;
+			-aix*)
+				vendor=ibm
+				;;
+			-beos*)
+				vendor=be
+				;;
+			-hpux*)
+				vendor=hp
+				;;
+			-mpeix*)
+				vendor=hp
+				;;
+			-hiux*)
+				vendor=hitachi
+				;;
+			-unos*)
+				vendor=crds
+				;;
+			-dgux*)
+				vendor=dg
+				;;
+			-luna*)
+				vendor=omron
+				;;
+			-genix*)
+				vendor=ns
+				;;
+			-mvs* | -opened*)
+				vendor=ibm
+				;;
+			-ptx*)
+				vendor=sequent
+				;;
+			-vxsim* | -vxworks*)
+				vendor=wrs
+				;;
+			-aux*)
+				vendor=apple
+				;;
+			-hms*)
+				vendor=hitachi
+				;;
+			-mpw* | -macos*)
+				vendor=apple
+				;;
+			-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+				vendor=atari
+				;;
+			-vos*)
+				vendor=stratus
+				;;
+		esac
+		basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+		;;
+esac
+
+echo $basic_machine$os
+exit 0
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:


Property changes on: experimental/j/Elphel333/rtp/daemon/rtp/config.sub
___________________________________________________________________
Name: svn:executable
   + 

Added: experimental/j/Elphel333/rtp/daemon/rtp/config_unix.h
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/config_unix.h	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/config_unix.h	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,203 @@
+/*
+ *  config-unix.h
+ *
+ *  Unix specific definitions and includes
+ *  
+ *  $Revision: 1.1.1.1 $
+ *  $Date: 2005/03/18 09:18:43 $
+ *
+ * Copyright (c) 1995-2000 University College London
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, is permitted provided that the following conditions 
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by the Computer Science
+ *      Department at University College London
+ * 4. Neither the name of the University nor of the Department may be used
+ *    to endorse or promote products derived from this software without
+ *    specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef WIN32
+#ifndef _CONFIG_UNIX_H
+#define _CONFIG_UNIX_H
+#undef VERSION
+#undef PACKAGE
+#include "uclconf.h"
+#undef VERSION
+#undef PACKAGE
+#include "win32_ver.h"
+#include <limits.h>
+#include <sys/types.h>
+#if TIME_WITH_SYS_TIME
+#include <sys/time.h>
+#include <time.h>
+#else
+#if HAVE_SYS_TIME_H
+#include <sys/time.h>
+#else
+#include <time.h>
+#endif
+#endif
+#include <sys/resource.h>
+
+#include <pwd.h>
+#include <signal.h>
+#include <ctype.h>
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <memory.h>
+#include <errno.h>
+#include <math.h>
+#include <stdlib.h>   /* abs() */
+#include <string.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/uio.h>
+#include <netinet/in.h>
+#include <unistd.h>
+#include <sys/param.h>
+
+#ifndef __QNXNTO__
+#include <sys/fcntl.h>
+#endif
+
+#include <sys/ioctl.h>
+#include <netdb.h>
+#include <arpa/inet.h>
+#include <syslog.h>
+#ifdef __APPLE__
+#define NEED_DRAND48
+#define srand48 srand
+#define lrand48 rand() * rand
+#endif
+
+#ifdef HAVE_SYS_WAIT_H
+#include <sys/wait.h>
+#endif
+#ifndef WEXITSTATUS
+#define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
+#endif
+#ifndef WIFEXITED
+#define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
+#endif
+
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#endif
+
+#ifdef HAVE_STROPTS_H
+#include <stropts.h>
+#endif /* HAVE_STROPTS_H */
+
+#ifdef HAVE_SYS_FILIO_H
+#include <sys/filio.h>  
+#endif /* HAVE_SYS_FILIO_H */
+
+#ifdef HAVE_IPv6
+
+#ifdef HAVE_NETINET6_IN6_H
+/* Expect IPV6_{JOIN,LEAVE}_GROUP in in6.h, otherwise expect                 */
+/* IPV_{ADD,DROP}_MEMBERSHIP in in.h                                         */
+#include <netinet6/in6.h>
+#else
+#ifdef HAVE_NETINET_IP6_H
+#include <netinet/ip6.h>
+#else
+#include <netinet/in.h>
+#endif
+#endif /* HAVE_NETINET_IN6_H */
+
+#ifndef IPV6_ADD_MEMBERSHIP
+#ifdef  IPV6_JOIN_GROUP
+#define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
+#else
+#error  No definition of IPV6_ADD_MEMBERSHIP, please report to mm-tools at cs.ucl.ac.uk.
+#endif /* IPV6_JOIN_GROUP     */
+#endif /* IPV6_ADD_MEMBERSHIP */
+
+#ifndef IPV6_DROP_MEMBERSHIP
+#ifdef  IPV6_LEAVE_GROUP
+#define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP
+#else
+#error  No definition of IPV6_LEAVE_GROUP, please report to mm-tools at cs.ucl.ac.uk.
+#endif  /* IPV6_LEAVE_GROUP     */
+#endif  /* IPV6_DROP_MEMBERSHIP */
+
+#endif /* HAVE_IPv6 */
+
+#include <net/if.h>
+
+typedef u_char	ttl_t;
+typedef int	fd_t;
+
+#ifndef FALSE
+#define FALSE	0
+#endif
+#ifndef TRUE
+#define	TRUE	1
+#endif /* TRUE */
+
+#define USERNAMELEN	8
+
+#ifndef max
+#define max(a, b)	(((a) > (b))? (a): (b))
+#endif
+#ifndef min
+#define min(a, b)	(((a) < (b))? (a): (b))
+#endif
+
+#if 1
+#define ASSERT(x) if ((x) == 0) fprintf(stderr, "%s:%u: failed assertion\n", __FILE__, __LINE__)
+#else
+#include <assert.h>
+#define ASSERT assert
+#endif
+
+#ifdef Solaris
+#ifdef __cplusplus
+extern "C" {
+#endif
+int gettimeofday(struct timeval *tp, void * );
+int gethostname(char *name, int namelen);
+#ifdef __cplusplus
+}
+#endif
+#endif
+
+#ifndef EXIT_SUCCESS
+#define EXIT_SUCCESS 0
+#endif /* EXIT_SUCCESS */
+
+#ifndef EXIT_FAILURE
+#define EXIT_FAILURE 7
+#endif /* EXIT_FAILURE */
+
+#endif /* _CONFIG_UNIX_H_ */
+#endif /* WIN32 */

Added: experimental/j/Elphel333/rtp/daemon/rtp/config_win32.h
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/config_win32.h	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/config_win32.h	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,226 @@
+/*
+ *  config-win32.h
+ *
+ *  Windows specific definitions and includes.
+ *  
+ *  $Revision: 1.1.1.1 $
+ *  $Date: 2005/03/18 09:18:48 $
+ *
+ * Copyright (c) 1995-2000 University College London
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, is permitted provided that the following conditions 
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by the Computer Science
+ *      Department at University College London
+ * 4. Neither the name of the University nor of the Department may be used
+ *    to endorse or promote products derived from this software without
+ *    specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifdef WIN32
+#ifndef _CONFIG_WIN32_H
+#define _CONFIG_WIN32_H
+
+#include <limits.h>
+#include <malloc.h>
+#include <stdio.h>
+#include <memory.h>
+#include <errno.h>
+#include <math.h>
+#include <stdlib.h>   /* abs() */
+#include <string.h>
+#include <winsock2.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#ifdef HAVE_IPv6
+#ifdef MUSICA_IPV6
+#include <winsock6.h>
+#else
+#ifdef WIN2K_IPV6
+#include <ws2tcpip.h>
+#include <tpipv6.h>
+#else
+#include <ws2ip6.h>
+#include <ws2tcpip.h>
+#endif
+#endif
+#endif
+
+#ifndef MUSICA_IPV6
+#include <ws2tcpip.h>
+#endif
+
+#include <mmreg.h>
+#include <msacm.h>
+#include <mmsystem.h>
+#include <windows.h>
+#include <io.h>
+#include <process.h>
+#include <fcntl.h>
+#include <time.h>
+#include <sys/timeb.h>
+
+typedef int		ttl_t;
+typedef unsigned int	fd_t;
+
+/*
+ * the definitions below are valid for 32-bit architectures and will have to
+ * be adjusted for 16- or 64-bit architectures
+ */
+typedef unsigned __int8		uint8_t;
+typedef unsigned __int16	uint16_t;
+typedef unsigned __int32	uint32_t;
+typedef unsigned __int64    uint64_t;
+typedef __int8		int8_t;
+typedef __int16		int16_t;
+typedef __int32		int32_t;
+typedef __int64		int64_t;
+typedef unsigned long	in_addr_t;
+
+#ifndef TRUE
+#define FALSE	0
+#define	TRUE	1
+#endif /* TRUE */
+
+#define USERNAMELEN	8
+
+#define WORDS_SMALLENDIAN
+#define NEED_INET_ATON
+#define NEED_DRAND48
+//#define NEED_GETTIMEOFDAY
+
+#ifdef NDEBUG
+#define ASSERT(x) if ((x) == 0) fprintf(stderr, "%s:%u: failed assertion\n", __FILE__, __LINE__)
+#else
+#define ASSERT assert
+#include <assert.h>
+#endif
+
+#include <time.h>		/* For clock_t */
+
+#define inline
+#define __inline     
+
+#define AUDIO_MICROPHONE	1
+#define AUDIO_LINE_IN		2
+#define AUDIO_CD            4
+#define AUDIO_SPEAKER		0
+#define AUDIO_HEADPHONE		1
+#define AUDIO_LINE_OUT		4
+
+#define srand48	srand
+#define lrand48 rand() * rand
+#define snprintf _snprintf
+
+#define IN_CLASSD(i)	(((long)(i) & 0xf0000000) == 0xe0000000)
+#define IN_MULTICAST(i)	IN_CLASSD(i)
+
+typedef char	*caddr_t;
+typedef int	ssize_t;
+
+typedef struct iovec {
+	caddr_t	iov_base;
+	ssize_t	iov_len;
+} iovec_t;
+
+struct msghdr {
+	caddr_t		msg_name;
+	int		msg_namelen;
+	struct iovec	*msg_iov;
+	int		msg_iovlen;
+	caddr_t		msg_accrights;
+	int		msg_accrightslen;
+};
+
+#ifndef MAXHOSTNAMELEN
+#define MAXHOSTNAMELEN	256
+#endif
+
+#define _SYS_NMLN	9
+struct utsname {
+	char sysname[_SYS_NMLN];
+	char nodename[_SYS_NMLN];
+	char release[_SYS_NMLN];
+	char version[_SYS_NMLN];
+	char machine[_SYS_NMLN];
+};
+
+struct timezone {
+	int tz_minuteswest;
+	int tz_dsttime;
+};
+
+typedef int pid_t;
+typedef int uid_t;
+typedef int gid_t;
+    
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+int uname(struct utsname *);
+int getopt(int, char * const *, const char *);
+int gethostid(void);
+int getuid(void);
+int getgid(void);
+#define getpid _getpid
+int nice(int);
+int usleep(unsigned int);
+
+
+const char * w32_make_version_info(char * rat_verion);
+
+#define strcasecmp  _stricmp
+#define strncasecmp _strnicmp
+
+int  RegGetValue(HKEY *, char *, char*, char*, int);
+void ShowMessage(int level, char *msg);
+
+#define bcopy(from,to,len) memcpy(to,from,len)
+
+#if defined(__cplusplus)
+}
+#endif
+
+#define ECONNREFUSED	WSAECONNREFUSED
+#define ENETUNREACH		WSAENETUNREACH
+#define EHOSTUNREACH	WSAEHOSTUNREACH
+#define EWOULDBLOCK		WSAEWOULDBLOCK
+
+#ifndef EAFNOSUPPORT
+#define EAFNOSUPPORT	WSAEAFNOSUPPORT
+#endif
+
+#define M_PI		3.14159265358979323846
+
+#endif 
+#define LOG_EMERG 0
+#define LOG_ALERT 1
+#define LOG_CRIT 2
+#define LOG_ERR 3
+#define LOG_WARNING 4
+#define LOG_NOTICE 5
+#define LOG_INFO 6
+#define LOG_DEBUG 7
+#endif

Added: experimental/j/Elphel333/rtp/daemon/rtp/configure
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/configure	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/configure	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,11748 @@
+#! /bin/sh
+# Guess values for system-dependent variables and create Makefiles.
+# Generated by GNU Autoconf 2.57.
+#
+# Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002
+# Free Software Foundation, Inc.
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+## --------------------- ##
+## M4sh Initialization.  ##
+## --------------------- ##
+
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
+  set -o posix
+fi
+
+# Support unset when possible.
+if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
+  as_unset=unset
+else
+  as_unset=false
+fi
+
+
+# Work around bugs in pre-3.0 UWIN ksh.
+$as_unset ENV MAIL MAILPATH
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+for as_var in \
+  LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
+  LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
+  LC_TELEPHONE LC_TIME
+do
+  if (set +x; test -n "`(eval $as_var=C; export $as_var) 2>&1`"); then
+    eval $as_var=C; export $as_var
+  else
+    $as_unset $as_var
+  fi
+done
+
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
+  as_basename=basename
+else
+  as_basename=false
+fi
+
+
+# Name of the executable.
+as_me=`$as_basename "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+	 X"$0" : 'X\(//\)$' \| \
+	 X"$0" : 'X\(/\)$' \| \
+	 .     : '\(.\)' 2>/dev/null ||
+echo X/"$0" |
+    sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
+  	  /^X\/\(\/\/\)$/{ s//\1/; q; }
+  	  /^X\/\(\/\).*/{ s//\1/; q; }
+  	  s/.*/./; q'`
+
+
+# PATH needs CR, and LINENO needs CR and PATH.
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  echo "#! /bin/sh" >conf$$.sh
+  echo  "exit 0"   >>conf$$.sh
+  chmod +x conf$$.sh
+  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+    PATH_SEPARATOR=';'
+  else
+    PATH_SEPARATOR=:
+  fi
+  rm -f conf$$.sh
+fi
+
+
+  as_lineno_1=$LINENO
+  as_lineno_2=$LINENO
+  as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+  test "x$as_lineno_1" != "x$as_lineno_2" &&
+  test "x$as_lineno_3"  = "x$as_lineno_2"  || {
+  # Find who we are.  Look in the path if we contain no path at all
+  # relative or not.
+  case $0 in
+    *[\\/]* ) as_myself=$0 ;;
+    *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+done
+
+       ;;
+  esac
+  # We did not find ourselves, most probably we were run as `sh COMMAND'
+  # in which case we are not to be found in the path.
+  if test "x$as_myself" = x; then
+    as_myself=$0
+  fi
+  if test ! -f "$as_myself"; then
+    { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2
+   { (exit 1); exit 1; }; }
+  fi
+  case $CONFIG_SHELL in
+  '')
+    as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for as_base in sh bash ksh sh5; do
+	 case $as_dir in
+	 /*)
+	   if ("$as_dir/$as_base" -c '
+  as_lineno_1=$LINENO
+  as_lineno_2=$LINENO
+  as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+  test "x$as_lineno_1" != "x$as_lineno_2" &&
+  test "x$as_lineno_3"  = "x$as_lineno_2" ') 2>/dev/null; then
+	     $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
+	     $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
+	     CONFIG_SHELL=$as_dir/$as_base
+	     export CONFIG_SHELL
+	     exec "$CONFIG_SHELL" "$0" ${1+"$@"}
+	   fi;;
+	 esac
+       done
+done
+;;
+  esac
+
+  # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
+  # uniformly replaced by the line number.  The first 'sed' inserts a
+  # line-number line before each line; the second 'sed' does the real
+  # work.  The second script uses 'N' to pair each line-number line
+  # with the numbered line, and appends trailing '-' during
+  # substitution so that $LINENO is not a special case at line end.
+  # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
+  # second 'sed' script.  Blame Lee E. McMahon for sed's syntax.  :-)
+  sed '=' <$as_myself |
+    sed '
+      N
+      s,$,-,
+      : loop
+      s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
+      t loop
+      s,-$,,
+      s,^['$as_cr_digits']*\n,,
+    ' >$as_me.lineno &&
+  chmod +x $as_me.lineno ||
+    { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
+   { (exit 1); exit 1; }; }
+
+  # Don't try to exec as it changes $[0], causing all sort of problems
+  # (the dirname of $[0] is not the place where we might find the
+  # original and so on.  Autoconf is especially sensible to this).
+  . ./$as_me.lineno
+  # Exit status is that of the last command.
+  exit
+}
+
+
+case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
+  *c*,-n*) ECHO_N= ECHO_C='
+' ECHO_T='	' ;;
+  *c*,*  ) ECHO_N=-n ECHO_C= ECHO_T= ;;
+  *)       ECHO_N= ECHO_C='\c' ECHO_T= ;;
+esac
+
+if expr a : '\(a\)' >/dev/null 2>&1; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+rm -f conf$$ conf$$.exe conf$$.file
+echo >conf$$.file
+if ln -s conf$$.file conf$$ 2>/dev/null; then
+  # We could just check for DJGPP; but this test a) works b) is more generic
+  # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
+  if test -f conf$$.exe; then
+    # Don't use ln at all; we don't have any links
+    as_ln_s='cp -p'
+  else
+    as_ln_s='ln -s'
+  fi
+elif ln conf$$.file conf$$ 2>/dev/null; then
+  as_ln_s=ln
+else
+  as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.file
+
+if mkdir -p . 2>/dev/null; then
+  as_mkdir_p=:
+else
+  as_mkdir_p=false
+fi
+
+as_executable_p="test -f"
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g"
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.
+as_nl='
+'
+IFS=" 	$as_nl"
+
+# CDPATH.
+$as_unset CDPATH
+
+
+# Find the correct PATH separator.  Usually this is `:', but
+# DJGPP uses `;' like DOS.
+if test "X${PATH_SEPARATOR+set}" != Xset; then
+  UNAME=${UNAME-`uname 2>/dev/null`}
+  case X$UNAME in
+    *-DOS) lt_cv_sys_path_separator=';' ;;
+    *)     lt_cv_sys_path_separator=':' ;;
+  esac
+  PATH_SEPARATOR=$lt_cv_sys_path_separator
+fi
+
+
+# Check that we are running under the correct shell.
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+case X$ECHO in
+X*--fallback-echo)
+  # Remove one level of quotation (which was required for Make).
+  ECHO=`echo "$ECHO" | sed 's,\\\\\$\\$0,'$0','`
+  ;;
+esac
+
+echo=${ECHO-echo}
+if test "X$1" = X--no-reexec; then
+  # Discard the --no-reexec flag, and continue.
+  shift
+elif test "X$1" = X--fallback-echo; then
+  # Avoid inline document here, it may be left over
+  :
+elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
+  # Yippee, $echo works!
+  :
+else
+  # Restart under the correct shell.
+  exec $SHELL "$0" --no-reexec ${1+"$@"}
+fi
+
+if test "X$1" = X--fallback-echo; then
+  # used as fallback echo
+  shift
+  cat <<EOF
+
+EOF
+  exit 0
+fi
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+if test "X${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi
+
+if test -z "$ECHO"; then
+if test "X${echo_test_string+set}" != Xset; then
+# find a string as large as possible, as long as the shell can cope with it
+  for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do
+    # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
+    if (echo_test_string="`eval $cmd`") 2>/dev/null &&
+       echo_test_string="`eval $cmd`" &&
+       (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null
+    then
+      break
+    fi
+  done
+fi
+
+if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
+   echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` &&
+   test "X$echo_testing_string" = "X$echo_test_string"; then
+  :
+else
+  # The Solaris, AIX, and Digital Unix default echo programs unquote
+  # backslashes.  This makes it impossible to quote backslashes using
+  #   echo "$something" | sed 's/\\/\\\\/g'
+  #
+  # So, first we look for a working echo in the user's PATH.
+
+  IFS="${IFS= 	}"; save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  for dir in $PATH /usr/ucb; do
+    if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
+       test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
+       echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` &&
+       test "X$echo_testing_string" = "X$echo_test_string"; then
+      echo="$dir/echo"
+      break
+    fi
+  done
+  IFS="$save_ifs"
+
+  if test "X$echo" = Xecho; then
+    # We didn't find a better echo, so look for alternatives.
+    if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' &&
+       echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` &&
+       test "X$echo_testing_string" = "X$echo_test_string"; then
+      # This shell has a builtin print -r that does the trick.
+      echo='print -r'
+    elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) &&
+	 test "X$CONFIG_SHELL" != X/bin/ksh; then
+      # If we have ksh, try running configure again with it.
+      ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
+      export ORIGINAL_CONFIG_SHELL
+      CONFIG_SHELL=/bin/ksh
+      export CONFIG_SHELL
+      exec $CONFIG_SHELL "$0" --no-reexec ${1+"$@"}
+    else
+      # Try using printf.
+      echo='printf %s\n'
+      if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
+	 echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` &&
+	 test "X$echo_testing_string" = "X$echo_test_string"; then
+	# Cool, printf works
+	:
+      elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` &&
+	   test "X$echo_testing_string" = 'X\t' &&
+	   echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
+	   test "X$echo_testing_string" = "X$echo_test_string"; then
+	CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL
+	export CONFIG_SHELL
+	SHELL="$CONFIG_SHELL"
+	export SHELL
+	echo="$CONFIG_SHELL $0 --fallback-echo"
+      elif echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` &&
+	   test "X$echo_testing_string" = 'X\t' &&
+	   echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
+	   test "X$echo_testing_string" = "X$echo_test_string"; then
+	echo="$CONFIG_SHELL $0 --fallback-echo"
+      else
+	# maybe with a smaller string...
+	prev=:
+
+	for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do
+	  if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null
+	  then
+	    break
+	  fi
+	  prev="$cmd"
+	done
+
+	if test "$prev" != 'sed 50q "$0"'; then
+	  echo_test_string=`eval $prev`
+	  export echo_test_string
+	  exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "$0" ${1+"$@"}
+	else
+	  # Oops.  We lost completely, so just stick with echo.
+	  echo=echo
+	fi
+      fi
+    fi
+  fi
+fi
+fi
+
+# Copy echo and quote the copy suitably for passing to libtool from
+# the Makefile, instead of quoting the original, which is used later.
+ECHO=$echo
+if test "X$ECHO" = "X$CONFIG_SHELL $0 --fallback-echo"; then
+   ECHO="$CONFIG_SHELL \\\$\$0 --fallback-echo"
+fi
+
+
+
+# Name of the host.
+# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
+# so uname gets run too.
+ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
+
+exec 6>&1
+
+#
+# Initializations.
+#
+ac_default_prefix=/usr/local
+ac_config_libobj_dir=.
+cross_compiling=no
+subdirs=
+MFLAGS=
+MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+# Maximum number of lines to put in a shell here document.
+# This variable seems obsolete.  It should probably be removed, and
+# only ac_max_sed_lines should be used.
+: ${ac_max_here_lines=38}
+
+# Identity of this package.
+PACKAGE_NAME=
+PACKAGE_TARNAME=
+PACKAGE_VERSION=
+PACKAGE_STRING=
+PACKAGE_BUGREPORT=
+
+ac_unique_file="base64.c"
+# Factoring default headers for most tests.
+ac_includes_default="\
+#include <stdio.h>
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#if STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# if HAVE_STDLIB_H
+#  include <stdlib.h>
+# endif
+#endif
+#if HAVE_STRING_H
+# if !STDC_HEADERS && HAVE_MEMORY_H
+#  include <memory.h>
+# endif
+# include <string.h>
+#endif
+#if HAVE_STRINGS_H
+# include <strings.h>
+#endif
+#if HAVE_INTTYPES_H
+# include <inttypes.h>
+#else
+# if HAVE_STDINT_H
+#  include <stdint.h>
+# endif
+#endif
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif"
+
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO AMTAR install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM AWK SET_MAKE build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CPP LN_S ECHO RANLIB ac_ct_RANLIB EGREP LIBTOOL LIBOBJS GTKDOC OPTDOC LTLIBOBJS'
+ac_subst_files=''
+
+# Initialize some variables set by options.
+ac_init_help=
+ac_init_version=false
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+cache_file=/dev/null
+exec_prefix=NONE
+no_create=
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+verbose=
+x_includes=NONE
+x_libraries=NONE
+
+# Installation directory options.
+# These are left unexpanded so users can "make install exec_prefix=/foo"
+# and all the variables that are supposed to be based on exec_prefix
+# by default will actually change.
+# Use braces instead of parens because sh, perl, etc. also accept them.
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datadir='${prefix}/share'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+libdir='${exec_prefix}/lib'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+infodir='${prefix}/info'
+mandir='${prefix}/man'
+
+ac_prev=
+for ac_option
+do
+  # If the previous option needs an argument, assign it.
+  if test -n "$ac_prev"; then
+    eval "$ac_prev=\$ac_option"
+    ac_prev=
+    continue
+  fi
+
+  ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
+
+  # Accept the important Cygnus configure options, so we can diagnose typos.
+
+  case $ac_option in
+
+  -bindir | --bindir | --bindi | --bind | --bin | --bi)
+    ac_prev=bindir ;;
+  -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+    bindir=$ac_optarg ;;
+
+  -build | --build | --buil | --bui | --bu)
+    ac_prev=build_alias ;;
+  -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+    build_alias=$ac_optarg ;;
+
+  -cache-file | --cache-file | --cache-fil | --cache-fi \
+  | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+    ac_prev=cache_file ;;
+  -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+  | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+    cache_file=$ac_optarg ;;
+
+  --config-cache | -C)
+    cache_file=config.cache ;;
+
+  -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
+    ac_prev=datadir ;;
+  -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
+  | --da=*)
+    datadir=$ac_optarg ;;
+
+  -disable-* | --disable-*)
+    ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+      { echo "$as_me: error: invalid feature name: $ac_feature" >&2
+   { (exit 1); exit 1; }; }
+    ac_feature=`echo $ac_feature | sed 's/-/_/g'`
+    eval "enable_$ac_feature=no" ;;
+
+  -enable-* | --enable-*)
+    ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+      { echo "$as_me: error: invalid feature name: $ac_feature" >&2
+   { (exit 1); exit 1; }; }
+    ac_feature=`echo $ac_feature | sed 's/-/_/g'`
+    case $ac_option in
+      *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
+      *) ac_optarg=yes ;;
+    esac
+    eval "enable_$ac_feature='$ac_optarg'" ;;
+
+  -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+  | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+  | --exec | --exe | --ex)
+    ac_prev=exec_prefix ;;
+  -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+  | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+  | --exec=* | --exe=* | --ex=*)
+    exec_prefix=$ac_optarg ;;
+
+  -gas | --gas | --ga | --g)
+    # Obsolete; use --with-gas.
+    with_gas=yes ;;
+
+  -help | --help | --hel | --he | -h)
+    ac_init_help=long ;;
+  -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
+    ac_init_help=recursive ;;
+  -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
+    ac_init_help=short ;;
+
+  -host | --host | --hos | --ho)
+    ac_prev=host_alias ;;
+  -host=* | --host=* | --hos=* | --ho=*)
+    host_alias=$ac_optarg ;;
+
+  -includedir | --includedir | --includedi | --included | --include \
+  | --includ | --inclu | --incl | --inc)
+    ac_prev=includedir ;;
+  -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+  | --includ=* | --inclu=* | --incl=* | --inc=*)
+    includedir=$ac_optarg ;;
+
+  -infodir | --infodir | --infodi | --infod | --info | --inf)
+    ac_prev=infodir ;;
+  -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+    infodir=$ac_optarg ;;
+
+  -libdir | --libdir | --libdi | --libd)
+    ac_prev=libdir ;;
+  -libdir=* | --libdir=* | --libdi=* | --libd=*)
+    libdir=$ac_optarg ;;
+
+  -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+  | --libexe | --libex | --libe)
+    ac_prev=libexecdir ;;
+  -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+  | --libexe=* | --libex=* | --libe=*)
+    libexecdir=$ac_optarg ;;
+
+  -localstatedir | --localstatedir | --localstatedi | --localstated \
+  | --localstate | --localstat | --localsta | --localst \
+  | --locals | --local | --loca | --loc | --lo)
+    ac_prev=localstatedir ;;
+  -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+  | --localstate=* | --localstat=* | --localsta=* | --localst=* \
+  | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
+    localstatedir=$ac_optarg ;;
+
+  -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+    ac_prev=mandir ;;
+  -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+    mandir=$ac_optarg ;;
+
+  -nfp | --nfp | --nf)
+    # Obsolete; use --without-fp.
+    with_fp=no ;;
+
+  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+  | --no-cr | --no-c | -n)
+    no_create=yes ;;
+
+  -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+    no_recursion=yes ;;
+
+  -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+  | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+  | --oldin | --oldi | --old | --ol | --o)
+    ac_prev=oldincludedir ;;
+  -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+  | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+  | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+    oldincludedir=$ac_optarg ;;
+
+  -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+    ac_prev=prefix ;;
+  -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+    prefix=$ac_optarg ;;
+
+  -program-prefix | --program-prefix | --program-prefi | --program-pref \
+  | --program-pre | --program-pr | --program-p)
+    ac_prev=program_prefix ;;
+  -program-prefix=* | --program-prefix=* | --program-prefi=* \
+  | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+    program_prefix=$ac_optarg ;;
+
+  -program-suffix | --program-suffix | --program-suffi | --program-suff \
+  | --program-suf | --program-su | --program-s)
+    ac_prev=program_suffix ;;
+  -program-suffix=* | --program-suffix=* | --program-suffi=* \
+  | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+    program_suffix=$ac_optarg ;;
+
+  -program-transform-name | --program-transform-name \
+  | --program-transform-nam | --program-transform-na \
+  | --program-transform-n | --program-transform- \
+  | --program-transform | --program-transfor \
+  | --program-transfo | --program-transf \
+  | --program-trans | --program-tran \
+  | --progr-tra | --program-tr | --program-t)
+    ac_prev=program_transform_name ;;
+  -program-transform-name=* | --program-transform-name=* \
+  | --program-transform-nam=* | --program-transform-na=* \
+  | --program-transform-n=* | --program-transform-=* \
+  | --program-transform=* | --program-transfor=* \
+  | --program-transfo=* | --program-transf=* \
+  | --program-trans=* | --program-tran=* \
+  | --progr-tra=* | --program-tr=* | --program-t=*)
+    program_transform_name=$ac_optarg ;;
+
+  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+  | -silent | --silent | --silen | --sile | --sil)
+    silent=yes ;;
+
+  -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+    ac_prev=sbindir ;;
+  -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+  | --sbi=* | --sb=*)
+    sbindir=$ac_optarg ;;
+
+  -sharedstatedir | --sharedstatedir | --sharedstatedi \
+  | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+  | --sharedst | --shareds | --shared | --share | --shar \
+  | --sha | --sh)
+    ac_prev=sharedstatedir ;;
+  -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+  | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+  | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+  | --sha=* | --sh=*)
+    sharedstatedir=$ac_optarg ;;
+
+  -site | --site | --sit)
+    ac_prev=site ;;
+  -site=* | --site=* | --sit=*)
+    site=$ac_optarg ;;
+
+  -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+    ac_prev=srcdir ;;
+  -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+    srcdir=$ac_optarg ;;
+
+  -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+  | --syscon | --sysco | --sysc | --sys | --sy)
+    ac_prev=sysconfdir ;;
+  -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+  | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+    sysconfdir=$ac_optarg ;;
+
+  -target | --target | --targe | --targ | --tar | --ta | --t)
+    ac_prev=target_alias ;;
+  -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+    target_alias=$ac_optarg ;;
+
+  -v | -verbose | --verbose | --verbos | --verbo | --verb)
+    verbose=yes ;;
+
+  -version | --version | --versio | --versi | --vers | -V)
+    ac_init_version=: ;;
+
+  -with-* | --with-*)
+    ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+      { echo "$as_me: error: invalid package name: $ac_package" >&2
+   { (exit 1); exit 1; }; }
+    ac_package=`echo $ac_package| sed 's/-/_/g'`
+    case $ac_option in
+      *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
+      *) ac_optarg=yes ;;
+    esac
+    eval "with_$ac_package='$ac_optarg'" ;;
+
+  -without-* | --without-*)
+    ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+      { echo "$as_me: error: invalid package name: $ac_package" >&2
+   { (exit 1); exit 1; }; }
+    ac_package=`echo $ac_package | sed 's/-/_/g'`
+    eval "with_$ac_package=no" ;;
+
+  --x)
+    # Obsolete; use --with-x.
+    with_x=yes ;;
+
+  -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+  | --x-incl | --x-inc | --x-in | --x-i)
+    ac_prev=x_includes ;;
+  -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+  | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+    x_includes=$ac_optarg ;;
+
+  -x-libraries | --x-libraries | --x-librarie | --x-librari \
+  | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+    ac_prev=x_libraries ;;
+  -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+  | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+    x_libraries=$ac_optarg ;;
+
+  -*) { echo "$as_me: error: unrecognized option: $ac_option
+Try \`$0 --help' for more information." >&2
+   { (exit 1); exit 1; }; }
+    ;;
+
+  *=*)
+    ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
+      { echo "$as_me: error: invalid variable name: $ac_envvar" >&2
+   { (exit 1); exit 1; }; }
+    ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`
+    eval "$ac_envvar='$ac_optarg'"
+    export $ac_envvar ;;
+
+  *)
+    # FIXME: should be removed in autoconf 3.0.
+    echo "$as_me: WARNING: you should use --build, --host, --target" >&2
+    expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+      echo "$as_me: WARNING: invalid host type: $ac_option" >&2
+    : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
+    ;;
+
+  esac
+done
+
+if test -n "$ac_prev"; then
+  ac_option=--`echo $ac_prev | sed 's/_/-/g'`
+  { echo "$as_me: error: missing argument to $ac_option" >&2
+   { (exit 1); exit 1; }; }
+fi
+
+# Be sure to have absolute paths.
+for ac_var in exec_prefix prefix
+do
+  eval ac_val=$`echo $ac_var`
+  case $ac_val in
+    [\\/$]* | ?:[\\/]* | NONE | '' ) ;;
+    *)  { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
+   { (exit 1); exit 1; }; };;
+  esac
+done
+
+# Be sure to have absolute paths.
+for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \
+              localstatedir libdir includedir oldincludedir infodir mandir
+do
+  eval ac_val=$`echo $ac_var`
+  case $ac_val in
+    [\\/$]* | ?:[\\/]* ) ;;
+    *)  { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
+   { (exit 1); exit 1; }; };;
+  esac
+done
+
+# There might be people who depend on the old broken behavior: `$host'
+# used to hold the argument of --host etc.
+# FIXME: To remove some day.
+build=$build_alias
+host=$host_alias
+target=$target_alias
+
+# FIXME: To remove some day.
+if test "x$host_alias" != x; then
+  if test "x$build_alias" = x; then
+    cross_compiling=maybe
+    echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
+    If a cross compiler is detected then cross compile mode will be used." >&2
+  elif test "x$build_alias" != "x$host_alias"; then
+    cross_compiling=yes
+  fi
+fi
+
+ac_tool_prefix=
+test -n "$host_alias" && ac_tool_prefix=$host_alias-
+
+test "$silent" = yes && exec 6>/dev/null
+
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+  ac_srcdir_defaulted=yes
+  # Try the directory containing this script, then its parent.
+  ac_confdir=`(dirname "$0") 2>/dev/null ||
+$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+         X"$0" : 'X\(//\)[^/]' \| \
+         X"$0" : 'X\(//\)$' \| \
+         X"$0" : 'X\(/\)' \| \
+         .     : '\(.\)' 2>/dev/null ||
+echo X"$0" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+  	  /^X\(\/\/\)$/{ s//\1/; q; }
+  	  /^X\(\/\).*/{ s//\1/; q; }
+  	  s/.*/./; q'`
+  srcdir=$ac_confdir
+  if test ! -r $srcdir/$ac_unique_file; then
+    srcdir=..
+  fi
+else
+  ac_srcdir_defaulted=no
+fi
+if test ! -r $srcdir/$ac_unique_file; then
+  if test "$ac_srcdir_defaulted" = yes; then
+    { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2
+   { (exit 1); exit 1; }; }
+  else
+    { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2
+   { (exit 1); exit 1; }; }
+  fi
+fi
+(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null ||
+  { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2
+   { (exit 1); exit 1; }; }
+srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'`
+ac_env_build_alias_set=${build_alias+set}
+ac_env_build_alias_value=$build_alias
+ac_cv_env_build_alias_set=${build_alias+set}
+ac_cv_env_build_alias_value=$build_alias
+ac_env_host_alias_set=${host_alias+set}
+ac_env_host_alias_value=$host_alias
+ac_cv_env_host_alias_set=${host_alias+set}
+ac_cv_env_host_alias_value=$host_alias
+ac_env_target_alias_set=${target_alias+set}
+ac_env_target_alias_value=$target_alias
+ac_cv_env_target_alias_set=${target_alias+set}
+ac_cv_env_target_alias_value=$target_alias
+ac_env_CC_set=${CC+set}
+ac_env_CC_value=$CC
+ac_cv_env_CC_set=${CC+set}
+ac_cv_env_CC_value=$CC
+ac_env_CFLAGS_set=${CFLAGS+set}
+ac_env_CFLAGS_value=$CFLAGS
+ac_cv_env_CFLAGS_set=${CFLAGS+set}
+ac_cv_env_CFLAGS_value=$CFLAGS
+ac_env_LDFLAGS_set=${LDFLAGS+set}
+ac_env_LDFLAGS_value=$LDFLAGS
+ac_cv_env_LDFLAGS_set=${LDFLAGS+set}
+ac_cv_env_LDFLAGS_value=$LDFLAGS
+ac_env_CPPFLAGS_set=${CPPFLAGS+set}
+ac_env_CPPFLAGS_value=$CPPFLAGS
+ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set}
+ac_cv_env_CPPFLAGS_value=$CPPFLAGS
+ac_env_CPP_set=${CPP+set}
+ac_env_CPP_value=$CPP
+ac_cv_env_CPP_set=${CPP+set}
+ac_cv_env_CPP_value=$CPP
+
+#
+# Report the --help message.
+#
+if test "$ac_init_help" = "long"; then
+  # Omit some internal or obsolete options to make the list less imposing.
+  # This message is too long to be a string in the A/UX 3.1 sh.
+  cat <<_ACEOF
+\`configure' configures this package to adapt to many kinds of systems.
+
+Usage: $0 [OPTION]... [VAR=VALUE]...
+
+To assign environment variables (e.g., CC, CFLAGS...), specify them as
+VAR=VALUE.  See below for descriptions of some of the useful variables.
+
+Defaults for the options are specified in brackets.
+
+Configuration:
+  -h, --help              display this help and exit
+      --help=short        display options specific to this package
+      --help=recursive    display the short help of all the included packages
+  -V, --version           display version information and exit
+  -q, --quiet, --silent   do not print \`checking...' messages
+      --cache-file=FILE   cache test results in FILE [disabled]
+  -C, --config-cache      alias for \`--cache-file=config.cache'
+  -n, --no-create         do not create output files
+      --srcdir=DIR        find the sources in DIR [configure dir or \`..']
+
+_ACEOF
+
+  cat <<_ACEOF
+Installation directories:
+  --prefix=PREFIX         install architecture-independent files in PREFIX
+                          [$ac_default_prefix]
+  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
+                          [PREFIX]
+
+By default, \`make install' will install all the files in
+\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc.  You can specify
+an installation prefix other than \`$ac_default_prefix' using \`--prefix',
+for instance \`--prefix=\$HOME'.
+
+For better control, use the options below.
+
+Fine tuning of the installation directories:
+  --bindir=DIR           user executables [EPREFIX/bin]
+  --sbindir=DIR          system admin executables [EPREFIX/sbin]
+  --libexecdir=DIR       program executables [EPREFIX/libexec]
+  --datadir=DIR          read-only architecture-independent data [PREFIX/share]
+  --sysconfdir=DIR       read-only single-machine data [PREFIX/etc]
+  --sharedstatedir=DIR   modifiable architecture-independent data [PREFIX/com]
+  --localstatedir=DIR    modifiable single-machine data [PREFIX/var]
+  --libdir=DIR           object code libraries [EPREFIX/lib]
+  --includedir=DIR       C header files [PREFIX/include]
+  --oldincludedir=DIR    C header files for non-gcc [/usr/include]
+  --infodir=DIR          info documentation [PREFIX/info]
+  --mandir=DIR           man documentation [PREFIX/man]
+_ACEOF
+
+  cat <<\_ACEOF
+
+Program names:
+  --program-prefix=PREFIX            prepend PREFIX to installed program names
+  --program-suffix=SUFFIX            append SUFFIX to installed program names
+  --program-transform-name=PROGRAM   run sed PROGRAM on installed program names
+
+System types:
+  --build=BUILD     configure for building on BUILD [guessed]
+  --host=HOST       cross-compile to build programs to run on HOST [BUILD]
+  --target=TARGET   configure for building compilers for TARGET [HOST]
+_ACEOF
+fi
+
+if test -n "$ac_init_help"; then
+
+  cat <<\_ACEOF
+
+Optional Features:
+  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
+  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
+  --disable-dependency-tracking Speeds up one-time builds
+  --enable-dependency-tracking  Do not reject slow dependency extractors
+  --enable-shared=PKGS  build shared libraries default=yes
+  --enable-static=PKGS  build static libraries default=yes
+  --enable-fast-install=PKGS  optimize for fast installation default=yes
+  --disable-libtool-lock  avoid locking (might break parallel builds)
+  --enable-profile        enable profiling
+  --enable-bounds         enable bounds checking
+  --enable-debug          enable debug messages and code
+  --enable-debug-mem      enable memory debugging code
+  --enable-ipv6           enable ipv6
+  --enable-kame-ipv6      enable kame implementation of ipv6
+
+Optional Packages:
+  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
+  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+  --with-gnu-ld           assume the C compiler uses GNU ld default=no
+  --with-pic              try to use only PIC/non-PIC objects default=use both
+
+Some influential environment variables:
+  CC          C compiler command
+  CFLAGS      C compiler flags
+  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
+              nonstandard directory <lib dir>
+  CPPFLAGS    C/C++ preprocessor flags, e.g. -I<include dir> if you have
+              headers in a nonstandard directory <include dir>
+  CPP         C preprocessor
+
+Use these variables to override the choices made by `configure' or to help
+it to find libraries and programs with nonstandard names/locations.
+
+_ACEOF
+fi
+
+if test "$ac_init_help" = "recursive"; then
+  # If there are subdirs, report their specific --help.
+  ac_popdir=`pwd`
+  for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
+    test -d $ac_dir || continue
+    ac_builddir=.
+
+if test "$ac_dir" != .; then
+  ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
+  # A "../" for each directory in $ac_dir_suffix.
+  ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
+else
+  ac_dir_suffix= ac_top_builddir=
+fi
+
+case $srcdir in
+  .)  # No --srcdir option.  We are building in place.
+    ac_srcdir=.
+    if test -z "$ac_top_builddir"; then
+       ac_top_srcdir=.
+    else
+       ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
+    fi ;;
+  [\\/]* | ?:[\\/]* )  # Absolute path.
+    ac_srcdir=$srcdir$ac_dir_suffix;
+    ac_top_srcdir=$srcdir ;;
+  *) # Relative path.
+    ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_builddir$srcdir ;;
+esac
+# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be
+# absolute.
+ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd`
+ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd`
+ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd`
+ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd`
+
+    cd $ac_dir
+    # Check for guested configure; otherwise get Cygnus style configure.
+    if test -f $ac_srcdir/configure.gnu; then
+      echo
+      $SHELL $ac_srcdir/configure.gnu  --help=recursive
+    elif test -f $ac_srcdir/configure; then
+      echo
+      $SHELL $ac_srcdir/configure  --help=recursive
+    elif test -f $ac_srcdir/configure.ac ||
+           test -f $ac_srcdir/configure.in; then
+      echo
+      $ac_configure --help
+    else
+      echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
+    fi
+    cd $ac_popdir
+  done
+fi
+
+test -n "$ac_init_help" && exit 0
+if $ac_init_version; then
+  cat <<\_ACEOF
+
+Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002
+Free Software Foundation, Inc.
+This configure script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it.
+_ACEOF
+  exit 0
+fi
+exec 5>config.log
+cat >&5 <<_ACEOF
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+
+It was created by $as_me, which was
+generated by GNU Autoconf 2.57.  Invocation command line was
+
+  $ $0 $@
+
+_ACEOF
+{
+cat <<_ASUNAME
+## --------- ##
+## Platform. ##
+## --------- ##
+
+hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
+/bin/uname -X     = `(/bin/uname -X) 2>/dev/null     || echo unknown`
+
+/bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`
+/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
+hostinfo               = `(hostinfo) 2>/dev/null               || echo unknown`
+/bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`
+/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`
+/bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`
+
+_ASUNAME
+
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  echo "PATH: $as_dir"
+done
+
+} >&5
+
+cat >&5 <<_ACEOF
+
+
+## ----------- ##
+## Core tests. ##
+## ----------- ##
+
+_ACEOF
+
+
+# Keep a trace of the command line.
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Strip out --silent because we don't want to record it for future runs.
+# Also quote any args containing shell meta-characters.
+# Make two passes to allow for proper duplicate-argument suppression.
+ac_configure_args=
+ac_configure_args0=
+ac_configure_args1=
+ac_sep=
+ac_must_keep_next=false
+for ac_pass in 1 2
+do
+  for ac_arg
+  do
+    case $ac_arg in
+    -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
+    -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+    | -silent | --silent | --silen | --sile | --sil)
+      continue ;;
+    *" "*|*"	"*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
+      ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    esac
+    case $ac_pass in
+    1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;;
+    2)
+      ac_configure_args1="$ac_configure_args1 '$ac_arg'"
+      if test $ac_must_keep_next = true; then
+        ac_must_keep_next=false # Got value, back to normal.
+      else
+        case $ac_arg in
+          *=* | --config-cache | -C | -disable-* | --disable-* \
+          | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
+          | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
+          | -with-* | --with-* | -without-* | --without-* | --x)
+            case "$ac_configure_args0 " in
+              "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
+            esac
+            ;;
+          -* ) ac_must_keep_next=true ;;
+        esac
+      fi
+      ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'"
+      # Get rid of the leading space.
+      ac_sep=" "
+      ;;
+    esac
+  done
+done
+$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; }
+$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; }
+
+# When interrupted or exit'd, cleanup temporary files, and complete
+# config.log.  We remove comments because anyway the quotes in there
+# would cause problems or look ugly.
+# WARNING: Be sure not to use single quotes in there, as some shells,
+# such as our DU 5.0 friend, will then `close' the trap.
+trap 'exit_status=$?
+  # Save into config.log some information that might help in debugging.
+  {
+    echo
+
+    cat <<\_ASBOX
+## ---------------- ##
+## Cache variables. ##
+## ---------------- ##
+_ASBOX
+    echo
+    # The following way of writing the cache mishandles newlines in values,
+{
+  (set) 2>&1 |
+    case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in
+    *ac_space=\ *)
+      sed -n \
+        "s/'"'"'/'"'"'\\\\'"'"''"'"'/g;
+    	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p"
+      ;;
+    *)
+      sed -n \
+        "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
+      ;;
+    esac;
+}
+    echo
+
+    cat <<\_ASBOX
+## ----------------- ##
+## Output variables. ##
+## ----------------- ##
+_ASBOX
+    echo
+    for ac_var in $ac_subst_vars
+    do
+      eval ac_val=$`echo $ac_var`
+      echo "$ac_var='"'"'$ac_val'"'"'"
+    done | sort
+    echo
+
+    if test -n "$ac_subst_files"; then
+      cat <<\_ASBOX
+## ------------- ##
+## Output files. ##
+## ------------- ##
+_ASBOX
+      echo
+      for ac_var in $ac_subst_files
+      do
+	eval ac_val=$`echo $ac_var`
+        echo "$ac_var='"'"'$ac_val'"'"'"
+      done | sort
+      echo
+    fi
+
+    if test -s confdefs.h; then
+      cat <<\_ASBOX
+## ----------- ##
+## confdefs.h. ##
+## ----------- ##
+_ASBOX
+      echo
+      sed "/^$/d" confdefs.h | sort
+      echo
+    fi
+    test "$ac_signal" != 0 &&
+      echo "$as_me: caught signal $ac_signal"
+    echo "$as_me: exit $exit_status"
+  } >&5
+  rm -f core core.* *.core &&
+  rm -rf conftest* confdefs* conf$$* $ac_clean_files &&
+    exit $exit_status
+     ' 0
+for ac_signal in 1 2 13 15; do
+  trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal
+done
+ac_signal=0
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -rf conftest* confdefs.h
+# AIX cpp loses on an empty file, so make sure it contains at least a newline.
+echo >confdefs.h
+
+# Predefined preprocessor variables.
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_NAME "$PACKAGE_NAME"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_VERSION "$PACKAGE_VERSION"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_STRING "$PACKAGE_STRING"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
+_ACEOF
+
+
+# Let the site file select an alternate cache file if it wants to.
+# Prefer explicitly selected file to automatically selected ones.
+if test -z "$CONFIG_SITE"; then
+  if test "x$prefix" != xNONE; then
+    CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
+  else
+    CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
+  fi
+fi
+for ac_site_file in $CONFIG_SITE; do
+  if test -r "$ac_site_file"; then
+    { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5
+echo "$as_me: loading site script $ac_site_file" >&6;}
+    sed 's/^/| /' "$ac_site_file" >&5
+    . "$ac_site_file"
+  fi
+done
+
+if test -r "$cache_file"; then
+  # Some versions of bash will fail to source /dev/null (special
+  # files actually), so we avoid doing that.
+  if test -f "$cache_file"; then
+    { echo "$as_me:$LINENO: loading cache $cache_file" >&5
+echo "$as_me: loading cache $cache_file" >&6;}
+    case $cache_file in
+      [\\/]* | ?:[\\/]* ) . $cache_file;;
+      *)                      . ./$cache_file;;
+    esac
+  fi
+else
+  { echo "$as_me:$LINENO: creating cache $cache_file" >&5
+echo "$as_me: creating cache $cache_file" >&6;}
+  >$cache_file
+fi
+
+# Check that the precious variables saved in the cache have kept the same
+# value.
+ac_cache_corrupted=false
+for ac_var in `(set) 2>&1 |
+               sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do
+  eval ac_old_set=\$ac_cv_env_${ac_var}_set
+  eval ac_new_set=\$ac_env_${ac_var}_set
+  eval ac_old_val="\$ac_cv_env_${ac_var}_value"
+  eval ac_new_val="\$ac_env_${ac_var}_value"
+  case $ac_old_set,$ac_new_set in
+    set,)
+      { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
+      ac_cache_corrupted=: ;;
+    ,set)
+      { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5
+echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
+      ac_cache_corrupted=: ;;
+    ,);;
+    *)
+      if test "x$ac_old_val" != "x$ac_new_val"; then
+        { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
+echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+        { echo "$as_me:$LINENO:   former value:  $ac_old_val" >&5
+echo "$as_me:   former value:  $ac_old_val" >&2;}
+        { echo "$as_me:$LINENO:   current value: $ac_new_val" >&5
+echo "$as_me:   current value: $ac_new_val" >&2;}
+        ac_cache_corrupted=:
+      fi;;
+  esac
+  # Pass precious variables to config.status.
+  if test "$ac_new_set" = set; then
+    case $ac_new_val in
+    *" "*|*"	"*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
+      ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
+    *) ac_arg=$ac_var=$ac_new_val ;;
+    esac
+    case " $ac_configure_args " in
+      *" '$ac_arg' "*) ;; # Avoid dups.  Use of quotes ensures accuracy.
+      *) ac_configure_args="$ac_configure_args '$ac_arg'" ;;
+    esac
+  fi
+done
+if $ac_cache_corrupted; then
+  { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5
+echo "$as_me: error: changes in the environment can compromise the build" >&2;}
+  { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
+echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+          ac_config_headers="$ac_config_headers uclconf.h:config.h.in"
+
+
+am__api_version="1.7"
+ac_aux_dir=
+for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
+  if test -f $ac_dir/install-sh; then
+    ac_aux_dir=$ac_dir
+    ac_install_sh="$ac_aux_dir/install-sh -c"
+    break
+  elif test -f $ac_dir/install.sh; then
+    ac_aux_dir=$ac_dir
+    ac_install_sh="$ac_aux_dir/install.sh -c"
+    break
+  elif test -f $ac_dir/shtool; then
+    ac_aux_dir=$ac_dir
+    ac_install_sh="$ac_aux_dir/shtool install -c"
+    break
+  fi
+done
+if test -z "$ac_aux_dir"; then
+  { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5
+echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+ac_config_guess="$SHELL $ac_aux_dir/config.guess"
+ac_config_sub="$SHELL $ac_aux_dir/config.sub"
+ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure.
+
+# Find a good install program.  We prefer a C program (faster),
+# so one script is as good as another.  But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AmigaOS /C/install, which installs bootblocks on floppy discs
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# ./install, which can be erroneously created by make from ./install.sh.
+echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5
+echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6
+if test -z "$INSTALL"; then
+if test "${ac_cv_path_install+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  # Account for people who put trailing slashes in PATH elements.
+case $as_dir/ in
+  ./ | .// | /cC/* | \
+  /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
+  /usr/ucb/* ) ;;
+  *)
+    # OSF1 and SCO ODT 3.0 have their own names for install.
+    # Don't use installbsd from OSF since it installs stuff as root
+    # by default.
+    for ac_prog in ginstall scoinst install; do
+      for ac_exec_ext in '' $ac_executable_extensions; do
+        if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
+          if test $ac_prog = install &&
+            grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+            # AIX install.  It has an incompatible calling convention.
+            :
+          elif test $ac_prog = install &&
+            grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+            # program-specific install script used by HP pwplus--don't use.
+            :
+          else
+            ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
+            break 3
+          fi
+        fi
+      done
+    done
+    ;;
+esac
+done
+
+
+fi
+  if test "${ac_cv_path_install+set}" = set; then
+    INSTALL=$ac_cv_path_install
+  else
+    # As a last resort, use the slow shell script.  We don't cache a
+    # path for INSTALL within a source directory, because that will
+    # break other packages using the cache if that directory is
+    # removed, or if the path is relative.
+    INSTALL=$ac_install_sh
+  fi
+fi
+echo "$as_me:$LINENO: result: $INSTALL" >&5
+echo "${ECHO_T}$INSTALL" >&6
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+echo "$as_me:$LINENO: checking whether build environment is sane" >&5
+echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6
+# Just in case
+sleep 1
+echo timestamp > conftest.file
+# Do `set' in a subshell so we don't clobber the current shell's
+# arguments.  Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+   set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
+   if test "$*" = "X"; then
+      # -L didn't work.
+      set X `ls -t $srcdir/configure conftest.file`
+   fi
+   rm -f conftest.file
+   if test "$*" != "X $srcdir/configure conftest.file" \
+      && test "$*" != "X conftest.file $srcdir/configure"; then
+
+      # If neither matched, then we have a broken ls.  This can happen
+      # if, for instance, CONFIG_SHELL is bash and it inherits a
+      # broken ls alias from the environment.  This has actually
+      # happened.  Such a system could not be considered "sane".
+      { { echo "$as_me:$LINENO: error: ls -t appears to fail.  Make sure there is not a broken
+alias in your environment" >&5
+echo "$as_me: error: ls -t appears to fail.  Make sure there is not a broken
+alias in your environment" >&2;}
+   { (exit 1); exit 1; }; }
+   fi
+
+   test "$2" = conftest.file
+   )
+then
+   # Ok.
+   :
+else
+   { { echo "$as_me:$LINENO: error: newly created file is older than distributed files!
+Check your system clock" >&5
+echo "$as_me: error: newly created file is older than distributed files!
+Check your system clock" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+test "$program_prefix" != NONE &&
+  program_transform_name="s,^,$program_prefix,;$program_transform_name"
+# Use a double $ so make ignores it.
+test "$program_suffix" != NONE &&
+  program_transform_name="s,\$,$program_suffix,;$program_transform_name"
+# Double any \ or $.  echo might interpret backslashes.
+# By default was `s,x,x', remove it if useless.
+cat <<\_ACEOF >conftest.sed
+s/[\\$]/&&/g;s/;s,x,x,$//
+_ACEOF
+program_transform_name=`echo $program_transform_name | sed -f conftest.sed`
+rm conftest.sed
+
+
+# expand $ac_aux_dir to an absolute path
+am_aux_dir=`cd $ac_aux_dir && pwd`
+
+test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing"
+# Use eval to expand $SHELL
+if eval "$MISSING --run true"; then
+  am_missing_run="$MISSING --run "
+else
+  am_missing_run=
+  { echo "$as_me:$LINENO: WARNING: \`missing' script is too old or missing" >&5
+echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;}
+fi
+
+for ac_prog in gawk mawk nawk awk
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_AWK+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$AWK"; then
+  ac_cv_prog_AWK="$AWK" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_AWK="$ac_prog"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+fi
+fi
+AWK=$ac_cv_prog_AWK
+if test -n "$AWK"; then
+  echo "$as_me:$LINENO: result: $AWK" >&5
+echo "${ECHO_T}$AWK" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  test -n "$AWK" && break
+done
+
+echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5
+echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6
+set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,./+-,__p_,'`
+if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.make <<\_ACEOF
+all:
+	@echo 'ac_maketemp="$(MAKE)"'
+_ACEOF
+# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=`
+if test -n "$ac_maketemp"; then
+  eval ac_cv_prog_make_${ac_make}_set=yes
+else
+  eval ac_cv_prog_make_${ac_make}_set=no
+fi
+rm -f conftest.make
+fi
+if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
+  echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+  SET_MAKE=
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+  SET_MAKE="MAKE=${MAKE-make}"
+fi
+
+ # test to see if srcdir already configured
+if test "`cd $srcdir && pwd`" != "`pwd`" &&
+   test -f $srcdir/config.status; then
+  { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5
+echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+# test whether we have cygpath
+if test -z "$CYGPATH_W"; then
+  if (cygpath --version) >/dev/null 2>/dev/null; then
+    CYGPATH_W='cygpath -w'
+  else
+    CYGPATH_W=echo
+  fi
+fi
+
+
+# Define the identity of the package.
+ PACKAGE=uclrtp
+ VERSION=1.2.8
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE "$PACKAGE"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define VERSION "$VERSION"
+_ACEOF
+
+# Some tools Automake needs.
+
+ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"}
+
+
+AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"}
+
+
+AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"}
+
+
+AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"}
+
+
+MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
+
+
+AMTAR=${AMTAR-"${am_missing_run}tar"}
+
+install_sh=${install_sh-"$am_aux_dir/install-sh"}
+
+# Installed binaries are usually stripped using `strip' when the user
+# run `make install-strip'.  However `strip' might not be the right
+# tool to use in cross-compilation environments, therefore Automake
+# will honor the `STRIP' environment variable to overrule this program.
+if test "$cross_compiling" != no; then
+  if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
+set dummy ${ac_tool_prefix}strip; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_STRIP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$STRIP"; then
+  ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_STRIP="${ac_tool_prefix}strip"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+fi
+fi
+STRIP=$ac_cv_prog_STRIP
+if test -n "$STRIP"; then
+  echo "$as_me:$LINENO: result: $STRIP" >&5
+echo "${ECHO_T}$STRIP" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$ac_cv_prog_STRIP"; then
+  ac_ct_STRIP=$STRIP
+  # Extract the first word of "strip", so it can be a program name with args.
+set dummy strip; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_STRIP"; then
+  ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_STRIP="strip"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+  test -z "$ac_cv_prog_ac_ct_STRIP" && ac_cv_prog_ac_ct_STRIP=":"
+fi
+fi
+ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
+if test -n "$ac_ct_STRIP"; then
+  echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5
+echo "${ECHO_T}$ac_ct_STRIP" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  STRIP=$ac_ct_STRIP
+else
+  STRIP="$ac_cv_prog_STRIP"
+fi
+
+fi
+INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s"
+
+# We need awk for the "check" target.  The system "awk" is bad on
+# some platforms.
+
+
+
+# Make sure we can run config.sub.
+$ac_config_sub sun4 >/dev/null 2>&1 ||
+  { { echo "$as_me:$LINENO: error: cannot run $ac_config_sub" >&5
+echo "$as_me: error: cannot run $ac_config_sub" >&2;}
+   { (exit 1); exit 1; }; }
+
+echo "$as_me:$LINENO: checking build system type" >&5
+echo $ECHO_N "checking build system type... $ECHO_C" >&6
+if test "${ac_cv_build+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_build_alias=$build_alias
+test -z "$ac_cv_build_alias" &&
+  ac_cv_build_alias=`$ac_config_guess`
+test -z "$ac_cv_build_alias" &&
+  { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5
+echo "$as_me: error: cannot guess build type; you must specify one" >&2;}
+   { (exit 1); exit 1; }; }
+ac_cv_build=`$ac_config_sub $ac_cv_build_alias` ||
+  { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_build_alias failed" >&5
+echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed" >&2;}
+   { (exit 1); exit 1; }; }
+
+fi
+echo "$as_me:$LINENO: result: $ac_cv_build" >&5
+echo "${ECHO_T}$ac_cv_build" >&6
+build=$ac_cv_build
+build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+
+
+echo "$as_me:$LINENO: checking host system type" >&5
+echo $ECHO_N "checking host system type... $ECHO_C" >&6
+if test "${ac_cv_host+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_host_alias=$host_alias
+test -z "$ac_cv_host_alias" &&
+  ac_cv_host_alias=$ac_cv_build_alias
+ac_cv_host=`$ac_config_sub $ac_cv_host_alias` ||
+  { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_host_alias failed" >&5
+echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;}
+   { (exit 1); exit 1; }; }
+
+fi
+echo "$as_me:$LINENO: result: $ac_cv_host" >&5
+echo "${ECHO_T}$ac_cv_host" >&6
+host=$ac_cv_host
+host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+
+
+echo "$as_me:$LINENO: checking target system type" >&5
+echo $ECHO_N "checking target system type... $ECHO_C" >&6
+if test "${ac_cv_target+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_target_alias=$target_alias
+test "x$ac_cv_target_alias" = "x" &&
+  ac_cv_target_alias=$ac_cv_host_alias
+ac_cv_target=`$ac_config_sub $ac_cv_target_alias` ||
+  { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_target_alias failed" >&5
+echo "$as_me: error: $ac_config_sub $ac_cv_target_alias failed" >&2;}
+   { (exit 1); exit 1; }; }
+
+fi
+echo "$as_me:$LINENO: result: $ac_cv_target" >&5
+echo "${ECHO_T}$ac_cv_target" >&6
+target=$ac_cv_target
+target_cpu=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+target_vendor=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+target_os=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+
+
+# The aliases save the names the user supplied, while $host etc.
+# will get canonicalized.
+test -n "$target_alias" &&
+  test "$program_prefix$program_suffix$program_transform_name" = \
+    NONENONEs,x,x, &&
+  program_prefix=${target_alias}-
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}gcc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_CC="${ac_tool_prefix}gcc"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+  ac_ct_CC=$CC
+  # Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_CC="gcc"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  CC=$ac_ct_CC
+else
+  CC="$ac_cv_prog_CC"
+fi
+
+if test -z "$CC"; then
+  if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}cc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_CC="${ac_tool_prefix}cc"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+  ac_ct_CC=$CC
+  # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_CC="cc"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  CC=$ac_ct_CC
+else
+  CC="$ac_cv_prog_CC"
+fi
+
+fi
+if test -z "$CC"; then
+  # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+  ac_prog_rejected=no
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
+       ac_prog_rejected=yes
+       continue
+     fi
+    ac_cv_prog_CC="cc"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+if test $ac_prog_rejected = yes; then
+  # We found a bogon in the path, so make sure we never use it.
+  set dummy $ac_cv_prog_CC
+  shift
+  if test $# != 0; then
+    # We chose a different compiler from the bogus one.
+    # However, it has the same basename, so the bogon will be chosen
+    # first if we set CC to just the basename; use the full file name.
+    shift
+    ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
+  fi
+fi
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$CC"; then
+  if test -n "$ac_tool_prefix"; then
+  for ac_prog in cl
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+    test -n "$CC" && break
+  done
+fi
+if test -z "$CC"; then
+  ac_ct_CC=$CC
+  for ac_prog in cl
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_CC="$ac_prog"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  test -n "$ac_ct_CC" && break
+done
+
+  CC=$ac_ct_CC
+fi
+
+fi
+
+
+test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
+See \`config.log' for more details." >&5
+echo "$as_me: error: no acceptable C compiler found in \$PATH
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+
+# Provide some information about the compiler.
+echo "$as_me:$LINENO:" \
+     "checking for C compiler version" >&5
+ac_compiler=`set X $ac_compile; echo $2`
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
+  (eval $ac_compiler --version </dev/null >&5) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5
+  (eval $ac_compiler -v </dev/null >&5) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5
+  (eval $ac_compiler -V </dev/null >&5) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files a.out a.exe b.out"
+# Try to create an executable without -o first, disregard a.out.
+# It will help us diagnose broken compilers, and finding out an intuition
+# of exeext.
+echo "$as_me:$LINENO: checking for C compiler default output" >&5
+echo $ECHO_N "checking for C compiler default output... $ECHO_C" >&6
+ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5
+  (eval $ac_link_default) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+  # Find the output, starting from the most likely.  This scheme is
+# not robust to junk in `.', hence go to wildcards (a.*) only as a last
+# resort.
+
+# Be careful to initialize this variable, since it used to be cached.
+# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile.
+ac_cv_exeext=
+# b.out is created by i960 compilers.
+for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out
+do
+  test -f "$ac_file" || continue
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj )
+        ;;
+    conftest.$ac_ext )
+        # This is the source file.
+        ;;
+    [ab].out )
+        # We found the default executable, but exeext='' is most
+        # certainly right.
+        break;;
+    *.* )
+        ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+        # FIXME: I believe we export ac_cv_exeext for Libtool,
+        # but it would be cool to find out if it's true.  Does anybody
+        # maintain Libtool? --akim.
+        export ac_cv_exeext
+        break;;
+    * )
+        break;;
+  esac
+done
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { echo "$as_me:$LINENO: error: C compiler cannot create executables
+See \`config.log' for more details." >&5
+echo "$as_me: error: C compiler cannot create executables
+See \`config.log' for more details." >&2;}
+   { (exit 77); exit 77; }; }
+fi
+
+ac_exeext=$ac_cv_exeext
+echo "$as_me:$LINENO: result: $ac_file" >&5
+echo "${ECHO_T}$ac_file" >&6
+
+# Check the compiler produces executables we can run.  If not, either
+# the compiler is broken, or we cross compile.
+echo "$as_me:$LINENO: checking whether the C compiler works" >&5
+echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6
+# FIXME: These cross compiler hacks should be removed for Autoconf 3.0
+# If not cross compiling, check that we can run a simple program.
+if test "$cross_compiling" != yes; then
+  if { ac_try='./$ac_file'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+    cross_compiling=no
+  else
+    if test "$cross_compiling" = maybe; then
+	cross_compiling=yes
+    else
+	{ { echo "$as_me:$LINENO: error: cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+    fi
+  fi
+fi
+echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+rm -f a.out a.exe conftest$ac_cv_exeext b.out
+ac_clean_files=$ac_clean_files_save
+# Check the compiler produces executables we can run.  If not, either
+# the compiler is broken, or we cross compile.
+echo "$as_me:$LINENO: checking whether we are cross compiling" >&5
+echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6
+echo "$as_me:$LINENO: result: $cross_compiling" >&5
+echo "${ECHO_T}$cross_compiling" >&6
+
+echo "$as_me:$LINENO: checking for suffix of executables" >&5
+echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+  # If both `conftest.exe' and `conftest' are `present' (well, observable)
+# catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
+# work properly (i.e., refer to `conftest.exe'), while it won't with
+# `rm'.
+for ac_file in conftest.exe conftest conftest.*; do
+  test -f "$ac_file" || continue
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;;
+    *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+          export ac_cv_exeext
+          break;;
+    * ) break;;
+  esac
+done
+else
+  { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+rm -f conftest$ac_cv_exeext
+echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5
+echo "${ECHO_T}$ac_cv_exeext" >&6
+
+rm -f conftest.$ac_ext
+EXEEXT=$ac_cv_exeext
+ac_exeext=$EXEEXT
+echo "$as_me:$LINENO: checking for suffix of object files" >&5
+echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6
+if test "${ac_cv_objext+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.o conftest.obj
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+  for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;;
+    *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
+       break;;
+  esac
+done
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+rm -f conftest.$ac_cv_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_objext" >&5
+echo "${ECHO_T}$ac_cv_objext" >&6
+OBJEXT=$ac_cv_objext
+ac_objext=$OBJEXT
+echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
+echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6
+if test "${ac_cv_c_compiler_gnu+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+#ifndef __GNUC__
+       choke me
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_compiler_gnu=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_compiler_gnu=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+ac_cv_c_compiler_gnu=$ac_compiler_gnu
+
+fi
+echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
+echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6
+GCC=`test $ac_compiler_gnu = yes && echo yes`
+ac_test_CFLAGS=${CFLAGS+set}
+ac_save_CFLAGS=$CFLAGS
+CFLAGS="-g"
+echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
+echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6
+if test "${ac_cv_prog_cc_g+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_prog_cc_g=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_prog_cc_g=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
+echo "${ECHO_T}$ac_cv_prog_cc_g" >&6
+if test "$ac_test_CFLAGS" = set; then
+  CFLAGS=$ac_save_CFLAGS
+elif test $ac_cv_prog_cc_g = yes; then
+  if test "$GCC" = yes; then
+    CFLAGS="-g -O2"
+  else
+    CFLAGS="-g"
+  fi
+else
+  if test "$GCC" = yes; then
+    CFLAGS="-O2"
+  else
+    CFLAGS=
+  fi
+fi
+echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5
+echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6
+if test "${ac_cv_prog_cc_stdc+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_prog_cc_stdc=no
+ac_save_CC=$CC
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <stdarg.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+     char **p;
+     int i;
+{
+  return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+  char *s;
+  va_list v;
+  va_start (v,p);
+  s = g (p, va_arg (v,int));
+  va_end (v);
+  return s;
+}
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+int
+main ()
+{
+return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
+  ;
+  return 0;
+}
+_ACEOF
+# Don't try gcc -ansi; that turns off useful extensions and
+# breaks some systems' header files.
+# AIX			-qlanglvl=ansi
+# Ultrix and OSF/1	-std1
+# HP-UX 10.20 and later	-Ae
+# HP-UX older versions	-Aa -D_HPUX_SOURCE
+# SVR4			-Xc -D__EXTENSIONS__
+for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+  CC="$ac_save_CC $ac_arg"
+  rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_prog_cc_stdc=$ac_arg
+break
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.$ac_objext
+done
+rm -f conftest.$ac_ext conftest.$ac_objext
+CC=$ac_save_CC
+
+fi
+
+case "x$ac_cv_prog_cc_stdc" in
+  x|xno)
+    echo "$as_me:$LINENO: result: none needed" >&5
+echo "${ECHO_T}none needed" >&6 ;;
+  *)
+    echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5
+echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6
+    CC="$CC $ac_cv_prog_cc_stdc" ;;
+esac
+
+# Some people use a C++ compiler to compile C.  Since we use `exit',
+# in C++ we need to declare it.  In case someone uses the same compiler
+# for both compiling C and C++ we need to have the C++ compiler decide
+# the declaration of exit, since it's the most demanding environment.
+cat >conftest.$ac_ext <<_ACEOF
+#ifndef __cplusplus
+  choke me
+#endif
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  for ac_declaration in \
+   ''\
+   '#include <stdlib.h>' \
+   'extern "C" void std::exit (int) throw (); using std::exit;' \
+   'extern "C" void std::exit (int); using std::exit;' \
+   'extern "C" void exit (int) throw ();' \
+   'extern "C" void exit (int);' \
+   'void exit (int);'
+do
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <stdlib.h>
+$ac_declaration
+int
+main ()
+{
+exit (42);
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+continue
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_declaration
+int
+main ()
+{
+exit (42);
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  break
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+done
+rm -f conftest*
+if test -n "$ac_declaration"; then
+  echo '#ifdef __cplusplus' >>confdefs.h
+  echo $ac_declaration      >>confdefs.h
+  echo '#endif'             >>confdefs.h
+fi
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+rm -f .deps 2>/dev/null
+mkdir .deps 2>/dev/null
+if test -d .deps; then
+  DEPDIR=.deps
+else
+  # MS-DOS does not allow filenames that begin with a dot.
+  DEPDIR=_deps
+fi
+rmdir .deps 2>/dev/null
+
+
+          ac_config_commands="$ac_config_commands depfiles"
+
+
+am_make=${MAKE-make}
+cat > confinc << 'END'
+doit:
+	@echo done
+END
+# If we don't find an include directive, just comment out the code.
+echo "$as_me:$LINENO: checking for style of include used by $am_make" >&5
+echo $ECHO_N "checking for style of include used by $am_make... $ECHO_C" >&6
+am__include="#"
+am__quote=
+_am_result=none
+# First try GNU make style include.
+echo "include confinc" > confmf
+# We grep out `Entering directory' and `Leaving directory'
+# messages which can occur if `w' ends up in MAKEFLAGS.
+# In particular we don't look at `^make:' because GNU make might
+# be invoked under some other name (usually "gmake"), in which
+# case it prints its new name instead of `make'.
+if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then
+   am__include=include
+   am__quote=
+   _am_result=GNU
+fi
+# Now try BSD make style include.
+if test "$am__include" = "#"; then
+   echo '.include "confinc"' > confmf
+   if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then
+      am__include=.include
+      am__quote="\""
+      _am_result=BSD
+   fi
+fi
+
+
+echo "$as_me:$LINENO: result: $_am_result" >&5
+echo "${ECHO_T}$_am_result" >&6
+rm -f confinc confmf
+
+# Check whether --enable-dependency-tracking or --disable-dependency-tracking was given.
+if test "${enable_dependency_tracking+set}" = set; then
+  enableval="$enable_dependency_tracking"
+
+fi;
+if test "x$enable_dependency_tracking" != xno; then
+  am_depcomp="$ac_aux_dir/depcomp"
+  AMDEPBACKSLASH='\'
+fi
+
+
+if test "x$enable_dependency_tracking" != xno; then
+  AMDEP_TRUE=
+  AMDEP_FALSE='#'
+else
+  AMDEP_TRUE='#'
+  AMDEP_FALSE=
+fi
+
+
+
+
+depcc="$CC"   am_compiler_list=
+
+echo "$as_me:$LINENO: checking dependency style of $depcc" >&5
+echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6
+if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+  # We make a subdir and do the tests there.  Otherwise we can end up
+  # making bogus files that we don't know about and never remove.  For
+  # instance it was reported that on HP-UX the gcc test will end up
+  # making a dummy file named `D' -- because `-MD' means `put the output
+  # in D'.
+  mkdir conftest.dir
+  # Copy depcomp to subdir because otherwise we won't find it if we're
+  # using a relative directory.
+  cp "$am_depcomp" conftest.dir
+  cd conftest.dir
+
+  am_cv_CC_dependencies_compiler_type=none
+  if test "$am_compiler_list" = ""; then
+     am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
+  fi
+  for depmode in $am_compiler_list; do
+    # We need to recreate these files for each test, as the compiler may
+    # overwrite some of them when testing with obscure command lines.
+    # This happens at least with the AIX C compiler.
+    echo '#include "conftest.h"' > conftest.c
+    echo 'int i;' > conftest.h
+    echo "${am__include} ${am__quote}conftest.Po${am__quote}" > confmf
+
+    case $depmode in
+    nosideeffect)
+      # after this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested
+      if test "x$enable_dependency_tracking" = xyes; then
+	continue
+      else
+	break
+      fi
+      ;;
+    none) break ;;
+    esac
+    # We check with `-c' and `-o' for the sake of the "dashmstdout"
+    # mode.  It turns out that the SunPro C++ compiler does not properly
+    # handle `-M -o', and we need to detect this.
+    if depmode=$depmode \
+       source=conftest.c object=conftest.o \
+       depfile=conftest.Po tmpdepfile=conftest.TPo \
+       $SHELL ./depcomp $depcc -c -o conftest.o conftest.c >/dev/null 2>&1 &&
+       grep conftest.h conftest.Po > /dev/null 2>&1 &&
+       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+      am_cv_CC_dependencies_compiler_type=$depmode
+      break
+    fi
+  done
+
+  cd ..
+  rm -rf conftest.dir
+else
+  am_cv_CC_dependencies_compiler_type=none
+fi
+
+fi
+echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5
+echo "${ECHO_T}$am_cv_CC_dependencies_compiler_type" >&6
+CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type
+
+
+
+if
+  test "x$enable_dependency_tracking" != xno \
+  && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then
+  am__fastdepCC_TRUE=
+  am__fastdepCC_FALSE='#'
+else
+  am__fastdepCC_TRUE='#'
+  am__fastdepCC_FALSE=
+fi
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
+echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+  CPP=
+fi
+if test -z "$CPP"; then
+  if test "${ac_cv_prog_CPP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+      # Double quotes because CPP needs to be expanded
+    for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
+    do
+      ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+                     Syntax error
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether non-existent headers
+  # can be detected and how.
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  # Broken: success on invalid input.
+continue
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+  break
+fi
+
+    done
+    ac_cv_prog_CPP=$CPP
+
+fi
+  CPP=$ac_cv_prog_CPP
+else
+  ac_cv_prog_CPP=$CPP
+fi
+echo "$as_me:$LINENO: result: $CPP" >&5
+echo "${ECHO_T}$CPP" >&6
+ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+                     Syntax error
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether non-existent headers
+  # can be detected and how.
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  # Broken: success on invalid input.
+continue
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+  :
+else
+  { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." >&5
+echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+# Check whether --enable-shared or --disable-shared was given.
+if test "${enable_shared+set}" = set; then
+  enableval="$enable_shared"
+  p=${PACKAGE-default}
+case $enableval in
+yes) enable_shared=yes ;;
+no) enable_shared=no ;;
+*)
+  enable_shared=no
+  # Look at the argument we got.  We use all the common list separators.
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
+  for pkg in $enableval; do
+    if test "X$pkg" = "X$p"; then
+      enable_shared=yes
+    fi
+  done
+  IFS="$ac_save_ifs"
+  ;;
+esac
+else
+  enable_shared=yes
+fi;
+# Check whether --enable-static or --disable-static was given.
+if test "${enable_static+set}" = set; then
+  enableval="$enable_static"
+  p=${PACKAGE-default}
+case $enableval in
+yes) enable_static=yes ;;
+no) enable_static=no ;;
+*)
+  enable_static=no
+  # Look at the argument we got.  We use all the common list separators.
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
+  for pkg in $enableval; do
+    if test "X$pkg" = "X$p"; then
+      enable_static=yes
+    fi
+  done
+  IFS="$ac_save_ifs"
+  ;;
+esac
+else
+  enable_static=yes
+fi;
+# Check whether --enable-fast-install or --disable-fast-install was given.
+if test "${enable_fast_install+set}" = set; then
+  enableval="$enable_fast_install"
+  p=${PACKAGE-default}
+case $enableval in
+yes) enable_fast_install=yes ;;
+no) enable_fast_install=no ;;
+*)
+  enable_fast_install=no
+  # Look at the argument we got.  We use all the common list separators.
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
+  for pkg in $enableval; do
+    if test "X$pkg" = "X$p"; then
+      enable_fast_install=yes
+    fi
+  done
+  IFS="$ac_save_ifs"
+  ;;
+esac
+else
+  enable_fast_install=yes
+fi;
+# Find the correct PATH separator.  Usually this is `:', but
+# DJGPP uses `;' like DOS.
+if test "X${PATH_SEPARATOR+set}" != Xset; then
+  UNAME=${UNAME-`uname 2>/dev/null`}
+  case X$UNAME in
+    *-DOS) lt_cv_sys_path_separator=';' ;;
+    *)     lt_cv_sys_path_separator=':' ;;
+  esac
+  PATH_SEPARATOR=$lt_cv_sys_path_separator
+fi
+
+
+# Check whether --with-gnu-ld or --without-gnu-ld was given.
+if test "${with_gnu_ld+set}" = set; then
+  withval="$with_gnu_ld"
+  test "$withval" = no || with_gnu_ld=yes
+else
+  with_gnu_ld=no
+fi;
+ac_prog=ld
+if test "$GCC" = yes; then
+  # Check if gcc -print-prog-name=ld gives a path.
+  echo "$as_me:$LINENO: checking for ld used by GCC" >&5
+echo $ECHO_N "checking for ld used by GCC... $ECHO_C" >&6
+  case $host in
+  *-*-mingw*)
+    # gcc leaves a trailing carriage return which upsets mingw
+    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+  *)
+    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+  esac
+  case $ac_prog in
+    # Accept absolute paths.
+    [\\/]* | [A-Za-z]:[\\/]*)
+      re_direlt='/[^/][^/]*/\.\./'
+      # Canonicalize the path of ld
+      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
+      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
+	ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
+      done
+      test -z "$LD" && LD="$ac_prog"
+      ;;
+  "")
+    # If it fails, then pretend we aren't using GCC.
+    ac_prog=ld
+    ;;
+  *)
+    # If it is relative, then search for the first ld in PATH.
+    with_gnu_ld=unknown
+    ;;
+  esac
+elif test "$with_gnu_ld" = yes; then
+  echo "$as_me:$LINENO: checking for GNU ld" >&5
+echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6
+else
+  echo "$as_me:$LINENO: checking for non-GNU ld" >&5
+echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6
+fi
+if test "${lt_cv_path_LD+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -z "$LD"; then
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  for ac_dir in $PATH; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+      lt_cv_path_LD="$ac_dir/$ac_prog"
+      # Check to see if the program is GNU ld.  I'd rather use --version,
+      # but apparently some GNU ld's only accept -v.
+      # Break only if it was the GNU/non-GNU ld that we prefer.
+      if "$lt_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
+	test "$with_gnu_ld" != no && break
+      else
+	test "$with_gnu_ld" != yes && break
+      fi
+    fi
+  done
+  IFS="$ac_save_ifs"
+else
+  lt_cv_path_LD="$LD" # Let the user override the test with a path.
+fi
+fi
+
+LD="$lt_cv_path_LD"
+if test -n "$LD"; then
+  echo "$as_me:$LINENO: result: $LD" >&5
+echo "${ECHO_T}$LD" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5
+echo "$as_me: error: no acceptable ld found in \$PATH" >&2;}
+   { (exit 1); exit 1; }; }
+echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5
+echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6
+if test "${lt_cv_prog_gnu_ld+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  # I'd rather use --version here, but apparently some GNU ld's only accept -v.
+if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
+  lt_cv_prog_gnu_ld=yes
+else
+  lt_cv_prog_gnu_ld=no
+fi
+fi
+echo "$as_me:$LINENO: result: $lt_cv_prog_gnu_ld" >&5
+echo "${ECHO_T}$lt_cv_prog_gnu_ld" >&6
+with_gnu_ld=$lt_cv_prog_gnu_ld
+
+
+echo "$as_me:$LINENO: checking for $LD option to reload object files" >&5
+echo $ECHO_N "checking for $LD option to reload object files... $ECHO_C" >&6
+if test "${lt_cv_ld_reload_flag+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_ld_reload_flag='-r'
+fi
+echo "$as_me:$LINENO: result: $lt_cv_ld_reload_flag" >&5
+echo "${ECHO_T}$lt_cv_ld_reload_flag" >&6
+reload_flag=$lt_cv_ld_reload_flag
+test -n "$reload_flag" && reload_flag=" $reload_flag"
+
+echo "$as_me:$LINENO: checking for BSD-compatible nm" >&5
+echo $ECHO_N "checking for BSD-compatible nm... $ECHO_C" >&6
+if test "${lt_cv_path_NM+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$NM"; then
+  # Let the user override the test.
+  lt_cv_path_NM="$NM"
+else
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do
+    test -z "$ac_dir" && ac_dir=.
+    tmp_nm=$ac_dir/${ac_tool_prefix}nm
+    if test -f $tmp_nm || test -f $tmp_nm$ac_exeext ; then
+      # Check to see if the nm accepts a BSD-compat flag.
+      # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+      #   nm: unknown option "B" ignored
+      # Tru64's nm complains that /dev/null is an invalid object file
+      if ($tmp_nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep '(/dev/null|Invalid file or object type)' >/dev/null; then
+	lt_cv_path_NM="$tmp_nm -B"
+	break
+      elif ($tmp_nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
+	lt_cv_path_NM="$tmp_nm -p"
+	break
+      else
+	lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+	continue # so that we can try to find one that supports BSD flags
+      fi
+    fi
+  done
+  IFS="$ac_save_ifs"
+  test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm
+fi
+fi
+
+NM="$lt_cv_path_NM"
+echo "$as_me:$LINENO: result: $NM" >&5
+echo "${ECHO_T}$NM" >&6
+
+echo "$as_me:$LINENO: checking for a sed that does not truncate output" >&5
+echo $ECHO_N "checking for a sed that does not truncate output... $ECHO_C" >&6
+if test "${lt_cv_path_SED+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  # Loop through the user's path and test for sed and gsed.
+# Then use that list of sed's as ones to test for truncation.
+as_executable_p="test -f"
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_prog in sed gsed; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
+        _sed_list="$_sed_list $as_dir/$ac_prog$ac_exec_ext"
+      fi
+    done
+  done
+done
+
+  # Create a temporary directory, and hook for its removal unless debugging.
+$debug ||
+{
+  trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0
+  trap '{ (exit 1); exit 1; }' 1 2 13 15
+}
+
+# Create a (secure) tmp directory for tmp files.
+: ${TMPDIR=/tmp}
+{
+  tmp=`(umask 077 && mktemp -d -q "$TMPDIR/sedXXXXXX") 2>/dev/null` &&
+  test -n "$tmp" && test -d "$tmp"
+}  ||
+{
+  tmp=$TMPDIR/sed$$-$RANDOM
+  (umask 077 && mkdir $tmp)
+} ||
+{
+   echo "$me: cannot create a temporary directory in $TMPDIR" >&2
+   { (exit 1); exit 1; }
+}
+  _max=0
+  _count=0
+  # Add /usr/xpg4/bin/sed as it is typically found on Solaris
+  # along with /bin/sed that truncates output.
+  for _sed in $_sed_list /usr/xpg4/bin/sed; do
+    test ! -f ${_sed} && break
+    cat /dev/null > "$tmp/sed.in"
+    _count=0
+    echo ${ECHO_N-$ac_n} "0123456789${ECHO_C-$ac_c}" >"$tmp/sed.in"
+    # Check for GNU sed and select it if it is found.
+    if "${_sed}" --version 2>&1 < /dev/null | egrep '(GNU)' > /dev/null; then
+      lt_cv_path_SED=${_sed}
+      break
+    fi
+    while true; do
+      cat "$tmp/sed.in" "$tmp/sed.in" >"$tmp/sed.tmp"
+      mv "$tmp/sed.tmp" "$tmp/sed.in"
+      cp "$tmp/sed.in" "$tmp/sed.nl"
+      echo >>"$tmp/sed.nl"
+      ${_sed} -e 's/a$//' < "$tmp/sed.nl" >"$tmp/sed.out" || break
+      cmp -s "$tmp/sed.out" "$tmp/sed.nl" || break
+      # 40000 chars as input seems more than enough
+      test $_count -gt 10 && break
+      _count=`expr $_count + 1`
+      if test $_count -gt $_max; then
+        _max=$_count
+        lt_cv_path_SED=$_sed
+      fi
+    done
+  done
+  rm -rf "$tmp"
+
+fi
+
+if test "X$SED" != "X"; then
+  lt_cv_path_SED=$SED
+else
+  SED=$lt_cv_path_SED
+fi
+echo "$as_me:$LINENO: result: $SED" >&5
+echo "${ECHO_T}$SED" >&6
+
+echo "$as_me:$LINENO: checking whether ln -s works" >&5
+echo $ECHO_N "checking whether ln -s works... $ECHO_C" >&6
+LN_S=$as_ln_s
+if test "$LN_S" = "ln -s"; then
+  echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+else
+  echo "$as_me:$LINENO: result: no, using $LN_S" >&5
+echo "${ECHO_T}no, using $LN_S" >&6
+fi
+
+echo "$as_me:$LINENO: checking how to recognise dependent libraries" >&5
+echo $ECHO_N "checking how to recognise dependent libraries... $ECHO_C" >&6
+if test "${lt_cv_deplibs_check_method+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_file_magic_cmd='$MAGIC_CMD'
+lt_cv_file_magic_test_file=
+lt_cv_deplibs_check_method='unknown'
+# Need to set the preceding variable on all platforms that support
+# interlibrary dependencies.
+# 'none' -- dependencies not supported.
+# `unknown' -- same as none, but documents that we really don't know.
+# 'pass_all' -- all dependencies passed with no checks.
+# 'test_compile' -- check by making test program.
+# 'file_magic [[regex]]' -- check by looking for files in library path
+# which responds to the $file_magic_cmd with a given egrep regex.
+# If you have `file' or equivalent on your system and you're not sure
+# whether `pass_all' will *always* work, you probably want this one.
+
+case $host_os in
+aix4* | aix5*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+beos*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+bsdi4*)
+  lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)'
+  lt_cv_file_magic_cmd='/usr/bin/file -L'
+  lt_cv_file_magic_test_file=/shlib/libc.so
+  ;;
+
+cygwin* | mingw* | pw32*)
+  lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
+  lt_cv_file_magic_cmd='$OBJDUMP -f'
+  ;;
+
+darwin* | rhapsody*)
+  lt_cv_deplibs_check_method='file_magic Mach-O dynamically linked shared library'
+  lt_cv_file_magic_cmd='/usr/bin/file -L'
+  case "$host_os" in
+  rhapsody* | darwin1.[012])
+    lt_cv_file_magic_test_file=`echo /System/Library/Frameworks/System.framework/Versions/*/System | head -1`
+    ;;
+  *) # Darwin 1.3 on
+    lt_cv_file_magic_test_file='/usr/lib/libSystem.dylib'
+    ;;
+  esac
+  ;;
+
+freebsd*)
+  if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+    case $host_cpu in
+    i*86 )
+      # Not sure whether the presence of OpenBSD here was a mistake.
+      # Let's accept both of them until this is cleared up.
+      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD)/i[3-9]86 (compact )?demand paged shared library'
+      lt_cv_file_magic_cmd=/usr/bin/file
+      lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
+      ;;
+    esac
+  else
+    lt_cv_deplibs_check_method=pass_all
+  fi
+  ;;
+
+gnu*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+hpux10.20*|hpux11*)
+  lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library'
+  lt_cv_file_magic_cmd=/usr/bin/file
+  lt_cv_file_magic_test_file=/usr/lib/libc.sl
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $host_os in
+  irix5* | nonstopux*)
+    # this will be overridden with pass_all, but let us keep it just in case
+    lt_cv_deplibs_check_method="file_magic ELF 32-bit MSB dynamic lib MIPS - version 1"
+    ;;
+  *)
+    case $LD in
+    *-32|*"-32 ") libmagic=32-bit;;
+    *-n32|*"-n32 ") libmagic=N32;;
+    *-64|*"-64 ") libmagic=64-bit;;
+    *) libmagic=never-match;;
+    esac
+    # this will be overridden with pass_all, but let us keep it just in case
+    lt_cv_deplibs_check_method="file_magic ELF ${libmagic} MSB mips-[1234] dynamic lib MIPS - version 1"
+    ;;
+  esac
+  lt_cv_file_magic_test_file=`echo /lib${libsuff}/libc.so*`
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+# This must be Linux ELF.
+linux*)
+  case $host_cpu in
+  alpha* | hppa* | i*86 | m68* | mips | mipsel | powerpc* | s390* | sparc* | ia64* | x86_64*)
+    lt_cv_deplibs_check_method=pass_all ;;
+  *)
+    # glibc up to 2.1.1 does not perform some relocations on ARM
+    lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' ;;
+  esac
+  lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+  ;;
+
+netbsd*)
+  if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+    lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+  else
+    lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so$'
+  fi
+  ;;
+
+newos6*)
+  lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)'
+  lt_cv_file_magic_cmd=/usr/bin/file
+  lt_cv_file_magic_test_file=/usr/lib/libnls.so
+  ;;
+
+openbsd*)
+  lt_cv_file_magic_cmd=/usr/bin/file
+  lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
+  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB shared object'
+  else
+    lt_cv_deplibs_check_method='file_magic OpenBSD.* shared library'
+  fi
+  ;;
+
+osf3* | osf4* | osf5*)
+  # this will be overridden with pass_all, but let us keep it just in case
+  lt_cv_deplibs_check_method='file_magic COFF format alpha shared library'
+  lt_cv_file_magic_test_file=/shlib/libc.so
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+sco3.2v5*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+solaris*)
+  lt_cv_deplibs_check_method=pass_all
+  lt_cv_file_magic_test_file=/lib/libc.so
+  ;;
+
+sysv5uw[78]* | sysv4*uw2*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+  case $host_vendor in
+  motorola)
+    lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]'
+    lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
+    ;;
+  ncr)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  sequent)
+    lt_cv_file_magic_cmd='/bin/file'
+    lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )'
+    ;;
+  sni)
+    lt_cv_file_magic_cmd='/bin/file'
+    lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib"
+    lt_cv_file_magic_test_file=/lib/libc.so
+    ;;
+  siemens)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  esac
+  ;;
+esac
+
+fi
+echo "$as_me:$LINENO: result: $lt_cv_deplibs_check_method" >&5
+echo "${ECHO_T}$lt_cv_deplibs_check_method" >&6
+file_magic_cmd=$lt_cv_file_magic_cmd
+deplibs_check_method=$lt_cv_deplibs_check_method
+
+
+
+
+
+
+
+
+# Check for command to grab the raw symbol name followed by C symbol from nm.
+echo "$as_me:$LINENO: checking command to parse $NM output" >&5
+echo $ECHO_N "checking command to parse $NM output... $ECHO_C" >&6
+if test "${lt_cv_sys_global_symbol_pipe+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+# These are sane defaults that work on at least a few old systems.
+# [They come from Ultrix.  What could be older than Ultrix?!! ;)]
+
+# Character class describing NM global symbol codes.
+symcode='[BCDEGRST]'
+
+# Regexp to match symbols that can be accessed directly from C.
+sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
+
+# Transform the above into a raw symbol and a C symbol.
+symxfrm='\1 \2\3 \3'
+
+# Transform an extracted symbol line into a proper C declaration
+lt_cv_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern char \1;/p'"
+
+# Transform an extracted symbol line into symbol name and symbol address
+lt_cv_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/  {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([^ ]*\) \([^ ]*\)$/  {\"\2\", (lt_ptr) \&\2},/p'"
+
+# Define system-specific variables.
+case $host_os in
+aix*)
+  symcode='[BCDT]'
+  ;;
+cygwin* | mingw* | pw32*)
+  symcode='[ABCDGISTW]'
+  ;;
+hpux*) # Its linker distinguishes data from code symbols
+  lt_cv_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern char \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+  lt_cv_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/  {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"\2\", (lt_ptr) \&\2},/p'"
+  ;;
+irix* | nonstopux*)
+  symcode='[BCDEGRST]'
+  ;;
+osf*)
+  symcode='[BCDEGQRST]'
+  ;;
+solaris* | sysv5*)
+  symcode='[BDT]'
+  ;;
+sysv4)
+  symcode='[DFNSTU]'
+  ;;
+esac
+
+# Handle CRLF in mingw tool chain
+opt_cr=
+case $host_os in
+mingw*)
+  opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp
+  ;;
+esac
+
+# If we're using GNU nm, then use its standard symbol codes.
+if $NM -V 2>&1 | egrep '(GNU|with BFD)' > /dev/null; then
+  symcode='[ABCDGISTW]'
+fi
+
+# Try without a prefix undercore, then with it.
+for ac_symprfx in "" "_"; do
+
+  # Write the raw and C identifiers.
+lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ 	]\($symcode$symcode*\)[ 	][ 	]*\($ac_symprfx\)$sympat$opt_cr$/$symxfrm/p'"
+
+  # Check to see that the pipe works correctly.
+  pipe_works=no
+  rm -f conftest*
+  cat > conftest.$ac_ext <<EOF
+#ifdef __cplusplus
+extern "C" {
+#endif
+char nm_test_var;
+void nm_test_func(){}
+#ifdef __cplusplus
+}
+#endif
+int main(){nm_test_var='a';nm_test_func();return(0);}
+EOF
+
+  if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+    # Now try to grab the symbols.
+    nlist=conftest.nm
+    if { (eval echo "$as_me:$LINENO: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\"") >&5
+  (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && test -s "$nlist"; then
+      # Try sorting and uniquifying the output.
+      if sort "$nlist" | uniq > "$nlist"T; then
+	mv -f "$nlist"T "$nlist"
+      else
+	rm -f "$nlist"T
+      fi
+
+      # Make sure that we snagged all the symbols we need.
+      if egrep ' nm_test_var$' "$nlist" >/dev/null; then
+	if egrep ' nm_test_func$' "$nlist" >/dev/null; then
+	  cat <<EOF > conftest.$ac_ext
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+EOF
+	  # Now generate the symbol file.
+	  eval "$lt_cv_global_symbol_to_cdecl"' < "$nlist" >> conftest.$ac_ext'
+
+	  cat <<EOF >> conftest.$ac_ext
+#if defined (__STDC__) && __STDC__
+# define lt_ptr void *
+#else
+# define lt_ptr char *
+# define const
+#endif
+
+/* The mapping between symbol names and symbols. */
+const struct {
+  const char *name;
+  lt_ptr address;
+}
+lt_preloaded_symbols[] =
+{
+EOF
+	  sed "s/^$symcode$symcode* \(.*\) \(.*\)$/  {\"\2\", (lt_ptr) \&\2},/" < "$nlist" >> conftest.$ac_ext
+	  cat <<\EOF >> conftest.$ac_ext
+  {0, (lt_ptr) 0}
+};
+
+#ifdef __cplusplus
+}
+#endif
+EOF
+	  # Now try linking the two files.
+	  mv conftest.$ac_objext conftstm.$ac_objext
+	  save_LIBS="$LIBS"
+	  save_CFLAGS="$CFLAGS"
+	  LIBS="conftstm.$ac_objext"
+	  CFLAGS="$CFLAGS$no_builtin_flag"
+	  if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && test -s conftest$ac_exeext; then
+	    pipe_works=yes
+	  fi
+	  LIBS="$save_LIBS"
+	  CFLAGS="$save_CFLAGS"
+	else
+	  echo "cannot find nm_test_func in $nlist" >&5
+	fi
+      else
+	echo "cannot find nm_test_var in $nlist" >&5
+      fi
+    else
+      echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5
+    fi
+  else
+    echo "$progname: failed program was:" >&5
+    cat conftest.$ac_ext >&5
+  fi
+  rm -f conftest* conftst*
+
+  # Do not use the global_symbol_pipe unless it works.
+  if test "$pipe_works" = yes; then
+    break
+  else
+    lt_cv_sys_global_symbol_pipe=
+  fi
+done
+
+fi
+
+global_symbol_pipe="$lt_cv_sys_global_symbol_pipe"
+if test -z "$lt_cv_sys_global_symbol_pipe"; then
+  global_symbol_to_cdecl=
+  global_symbol_to_c_name_address=
+else
+  global_symbol_to_cdecl="$lt_cv_global_symbol_to_cdecl"
+  global_symbol_to_c_name_address="$lt_cv_global_symbol_to_c_name_address"
+fi
+if test -z "$global_symbol_pipe$global_symbol_to_cdec$global_symbol_to_c_name_address";
+then
+  echo "$as_me:$LINENO: result: failed" >&5
+echo "${ECHO_T}failed" >&6
+else
+  echo "$as_me:$LINENO: result: ok" >&5
+echo "${ECHO_T}ok" >&6
+fi
+
+
+echo "$as_me:$LINENO: checking for egrep" >&5
+echo $ECHO_N "checking for egrep... $ECHO_C" >&6
+if test "${ac_cv_prog_egrep+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if echo a | (grep -E '(a|b)') >/dev/null 2>&1
+    then ac_cv_prog_egrep='grep -E'
+    else ac_cv_prog_egrep='egrep'
+    fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5
+echo "${ECHO_T}$ac_cv_prog_egrep" >&6
+ EGREP=$ac_cv_prog_egrep
+
+
+echo "$as_me:$LINENO: checking for ANSI C header files" >&5
+echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
+if test "${ac_cv_header_stdc+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_header_stdc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_header_stdc=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "memchr" >/dev/null 2>&1; then
+  :
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "free" >/dev/null 2>&1; then
+  :
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+  if test "$cross_compiling" = yes; then
+  :
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <ctype.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+                   (('a' <= (c) && (c) <= 'i') \
+                     || ('j' <= (c) && (c) <= 'r') \
+                     || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+  int i;
+  for (i = 0; i < 256; i++)
+    if (XOR (islower (i), ISLOWER (i))
+        || toupper (i) != TOUPPER (i))
+      exit(2);
+  exit (0);
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  :
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_header_stdc=no
+fi
+rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
+echo "${ECHO_T}$ac_cv_header_stdc" >&6
+if test $ac_cv_header_stdc = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define STDC_HEADERS 1
+_ACEOF
+
+fi
+
+# On IRIX 5.3, sys/types and inttypes.h are conflicting.
+
+
+
+
+
+
+
+
+
+for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
+                  inttypes.h stdint.h unistd.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  eval "$as_ac_Header=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "$as_ac_Header=no"
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+
+for ac_header in dlfcn.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+else
+  # Is the header compilable?
+echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_header_compiler=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc in
+  yes:no )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    (
+      cat <<\_ASBOX
+## ------------------------------------ ##
+## Report this to bug-autoconf at gnu.org. ##
+## ------------------------------------ ##
+_ASBOX
+    ) |
+      sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+  no:yes )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    (
+      cat <<\_ASBOX
+## ------------------------------------ ##
+## Report this to bug-autoconf at gnu.org. ##
+## ------------------------------------ ##
+_ASBOX
+    ) |
+      sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=$ac_header_preproc"
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+
+
+
+
+# Only perform the check for file, if the check method requires it
+case $deplibs_check_method in
+file_magic*)
+  if test "$file_magic_cmd" = '$MAGIC_CMD'; then
+    echo "$as_me:$LINENO: checking for ${ac_tool_prefix}file" >&5
+echo $ECHO_N "checking for ${ac_tool_prefix}file... $ECHO_C" >&6
+if test "${lt_cv_path_MAGIC_CMD+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  case $MAGIC_CMD in
+  /*)
+  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  ;;
+  ?:/*)
+  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a dos path.
+  ;;
+  *)
+  ac_save_MAGIC_CMD="$MAGIC_CMD"
+  IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="/usr/bin:$PATH"
+  for ac_dir in $ac_dummy; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/${ac_tool_prefix}file; then
+      lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file"
+      if test -n "$file_magic_test_file"; then
+	case $deplibs_check_method in
+	"file_magic "*)
+	  file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`"
+	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+	    egrep "$file_magic_regex" > /dev/null; then
+	    :
+	  else
+	    cat <<EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such.  This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem.  Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool at gnu.org
+
+EOF
+	  fi ;;
+	esac
+      fi
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+  MAGIC_CMD="$ac_save_MAGIC_CMD"
+  ;;
+esac
+fi
+
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+  echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5
+echo "${ECHO_T}$MAGIC_CMD" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+if test -z "$lt_cv_path_MAGIC_CMD"; then
+  if test -n "$ac_tool_prefix"; then
+    echo "$as_me:$LINENO: checking for file" >&5
+echo $ECHO_N "checking for file... $ECHO_C" >&6
+if test "${lt_cv_path_MAGIC_CMD+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  case $MAGIC_CMD in
+  /*)
+  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  ;;
+  ?:/*)
+  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a dos path.
+  ;;
+  *)
+  ac_save_MAGIC_CMD="$MAGIC_CMD"
+  IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="/usr/bin:$PATH"
+  for ac_dir in $ac_dummy; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/file; then
+      lt_cv_path_MAGIC_CMD="$ac_dir/file"
+      if test -n "$file_magic_test_file"; then
+	case $deplibs_check_method in
+	"file_magic "*)
+	  file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`"
+	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+	    egrep "$file_magic_regex" > /dev/null; then
+	    :
+	  else
+	    cat <<EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such.  This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem.  Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool at gnu.org
+
+EOF
+	  fi ;;
+	esac
+      fi
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+  MAGIC_CMD="$ac_save_MAGIC_CMD"
+  ;;
+esac
+fi
+
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+  echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5
+echo "${ECHO_T}$MAGIC_CMD" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  else
+    MAGIC_CMD=:
+  fi
+fi
+
+  fi
+  ;;
+esac
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ranlib; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_RANLIB+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$RANLIB"; then
+  ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+fi
+fi
+RANLIB=$ac_cv_prog_RANLIB
+if test -n "$RANLIB"; then
+  echo "$as_me:$LINENO: result: $RANLIB" >&5
+echo "${ECHO_T}$RANLIB" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$ac_cv_prog_RANLIB"; then
+  ac_ct_RANLIB=$RANLIB
+  # Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_RANLIB"; then
+  ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_RANLIB="ranlib"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+  test -z "$ac_cv_prog_ac_ct_RANLIB" && ac_cv_prog_ac_ct_RANLIB=":"
+fi
+fi
+ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
+if test -n "$ac_ct_RANLIB"; then
+  echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5
+echo "${ECHO_T}$ac_ct_RANLIB" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  RANLIB=$ac_ct_RANLIB
+else
+  RANLIB="$ac_cv_prog_RANLIB"
+fi
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
+set dummy ${ac_tool_prefix}strip; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_STRIP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$STRIP"; then
+  ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_STRIP="${ac_tool_prefix}strip"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+fi
+fi
+STRIP=$ac_cv_prog_STRIP
+if test -n "$STRIP"; then
+  echo "$as_me:$LINENO: result: $STRIP" >&5
+echo "${ECHO_T}$STRIP" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$ac_cv_prog_STRIP"; then
+  ac_ct_STRIP=$STRIP
+  # Extract the first word of "strip", so it can be a program name with args.
+set dummy strip; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_STRIP"; then
+  ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_STRIP="strip"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+  test -z "$ac_cv_prog_ac_ct_STRIP" && ac_cv_prog_ac_ct_STRIP=":"
+fi
+fi
+ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
+if test -n "$ac_ct_STRIP"; then
+  echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5
+echo "${ECHO_T}$ac_ct_STRIP" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  STRIP=$ac_ct_STRIP
+else
+  STRIP="$ac_cv_prog_STRIP"
+fi
+
+
+enable_dlopen=no
+enable_win32_dll=no
+
+# Check whether --enable-libtool-lock or --disable-libtool-lock was given.
+if test "${enable_libtool_lock+set}" = set; then
+  enableval="$enable_libtool_lock"
+
+fi;
+test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+
+# Some flags need to be propagated to the compiler or linker for good
+# libtool support.
+case $host in
+*-*-irix6*)
+  # Find out which ABI we are using.
+  echo '#line 4593 "configure"' > conftest.$ac_ext
+  if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+    case `/usr/bin/file conftest.$ac_objext` in
+    *32-bit*)
+      LD="${LD-ld} -32"
+      ;;
+    *N32*)
+      LD="${LD-ld} -n32"
+      ;;
+    *64-bit*)
+      LD="${LD-ld} -64"
+      ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+
+*-*-linux*)
+  # Test if the compiler is 64bit
+  echo 'int i;' > conftest.$ac_ext
+  lt_cv_cc_64bit_output=no
+  if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+    case `/usr/bin/file conftest.$ac_objext` in
+    *"ELF 64"*)
+      lt_cv_cc_64bit_output=yes
+      ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+
+*-*-sco3.2v5*)
+  # On SCO OpenServer 5, we need -belf to get full-featured binaries.
+  SAVE_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -belf"
+  echo "$as_me:$LINENO: checking whether the C compiler needs -belf" >&5
+echo $ECHO_N "checking whether the C compiler needs -belf... $ECHO_C" >&6
+if test "${lt_cv_cc_needs_belf+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+
+     ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+     cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  lt_cv_cc_needs_belf=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+lt_cv_cc_needs_belf=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+     ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+fi
+echo "$as_me:$LINENO: result: $lt_cv_cc_needs_belf" >&5
+echo "${ECHO_T}$lt_cv_cc_needs_belf" >&6
+  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
+    CFLAGS="$SAVE_CFLAGS"
+  fi
+  ;;
+
+
+esac
+
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed='sed -e s/^X//'
+sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g'
+
+# Same as above, but do not quote variable references.
+double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g'
+
+# Sed substitution to delay expansion of an escaped shell variable in a
+# double_quote_subst'ed string.
+delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
+
+# Constants:
+rm="rm -f"
+
+# Global variables:
+default_ofile=libtool
+can_build_shared=yes
+
+# All known linkers require a `.a' archive for static linking (except M$VC,
+# which needs '.lib').
+libext=a
+ltmain="$ac_aux_dir/ltmain.sh"
+ofile="$default_ofile"
+with_gnu_ld="$lt_cv_prog_gnu_ld"
+need_locks="$enable_libtool_lock"
+
+old_CC="$CC"
+old_CFLAGS="$CFLAGS"
+
+# Set sane defaults for various variables
+test -z "$AR" && AR=ar
+test -z "$AR_FLAGS" && AR_FLAGS=cru
+test -z "$AS" && AS=as
+test -z "$CC" && CC=cc
+test -z "$DLLTOOL" && DLLTOOL=dlltool
+test -z "$LD" && LD=ld
+test -z "$LN_S" && LN_S="ln -s"
+test -z "$MAGIC_CMD" && MAGIC_CMD=file
+test -z "$NM" && NM=nm
+test -z "$OBJDUMP" && OBJDUMP=objdump
+test -z "$RANLIB" && RANLIB=:
+test -z "$STRIP" && STRIP=:
+test -z "$ac_objext" && ac_objext=o
+
+if test x"$host" != x"$build"; then
+  ac_tool_prefix=${host_alias}-
+else
+  ac_tool_prefix=
+fi
+
+case $host_os in
+aix3*)
+  # AIX sometimes has problems with the GCC collect2 program.  For some
+  # reason, if we set the COLLECT_NAMES environment variable, the problems
+  # vanish in a puff of smoke.
+  if test "X${COLLECT_NAMES+set}" != Xset; then
+    COLLECT_NAMES=
+    export COLLECT_NAMES
+  fi
+  ;;
+esac
+
+# Determine commands to create old-style static archives.
+old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs'
+old_postinstall_cmds='chmod 644 $oldlib'
+old_postuninstall_cmds=
+
+if test -n "$RANLIB"; then
+  case $host_os in
+  openbsd*)
+    old_postinstall_cmds="\$RANLIB -t \$oldlib~$old_postinstall_cmds"
+    ;;
+  *)
+    old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds"
+    ;;
+  esac
+  old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
+fi
+
+# Allow CC to be a program name with arguments.
+set dummy $CC
+compiler="$2"
+
+echo "$as_me:$LINENO: checking for objdir" >&5
+echo $ECHO_N "checking for objdir... $ECHO_C" >&6
+rm -f .libs 2>/dev/null
+mkdir .libs 2>/dev/null
+if test -d .libs; then
+  objdir=.libs
+else
+  # MS-DOS does not allow filenames that begin with a dot.
+  objdir=_libs
+fi
+rmdir .libs 2>/dev/null
+echo "$as_me:$LINENO: result: $objdir" >&5
+echo "${ECHO_T}$objdir" >&6
+
+
+
+# Check whether --with-pic or --without-pic was given.
+if test "${with_pic+set}" = set; then
+  withval="$with_pic"
+  pic_mode="$withval"
+else
+  pic_mode=default
+fi;
+test -z "$pic_mode" && pic_mode=default
+
+# We assume here that the value for lt_cv_prog_cc_pic will not be cached
+# in isolation, and that seeing it set (from the cache) indicates that
+# the associated values are set (in the cache) correctly too.
+echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5
+echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6
+if test "${lt_cv_prog_cc_pic+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+   lt_cv_prog_cc_pic=
+  lt_cv_prog_cc_shlib=
+  lt_cv_prog_cc_wl=
+  lt_cv_prog_cc_static=
+  lt_cv_prog_cc_no_builtin=
+  lt_cv_prog_cc_can_build_shared=$can_build_shared
+
+  if test "$GCC" = yes; then
+    lt_cv_prog_cc_wl='-Wl,'
+    lt_cv_prog_cc_static='-static'
+
+    case $host_os in
+    aix*)
+      # Below there is a dirty hack to force normal static linking with -ldl
+      # The problem is because libdl dynamically linked with both libc and
+      # libC (AIX C++ library), which obviously doesn't included in libraries
+      # list by gcc. This cause undefined symbols with -static flags.
+      # This hack allows C programs to be linked with "-static -ldl", but
+      # not sure about C++ programs.
+      lt_cv_prog_cc_static="$lt_cv_prog_cc_static ${lt_cv_prog_cc_wl}-lC"
+      ;;
+    amigaos*)
+      # FIXME: we need at least 68020 code to build shared libraries, but
+      # adding the `-m68020' flag to GCC prevents building anything better,
+      # like `-m68040'.
+      lt_cv_prog_cc_pic='-m68020 -resident32 -malways-restore-a4'
+      ;;
+    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+      # PIC is the default for these OSes.
+      ;;
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      lt_cv_prog_cc_pic='-fno-common'
+      ;;
+    cygwin* | mingw* | pw32* | os2*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      lt_cv_prog_cc_pic='-DDLL_EXPORT'
+      ;;
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	 lt_cv_prog_cc_pic=-Kconform_pic
+      fi
+      ;;
+    *)
+      lt_cv_prog_cc_pic='-fPIC'
+      ;;
+    esac
+  else
+    # PORTME Check for PIC flags for the system compiler.
+    case $host_os in
+    aix3* | aix4* | aix5*)
+      lt_cv_prog_cc_wl='-Wl,'
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	lt_cv_prog_cc_static='-Bstatic'
+      else
+	lt_cv_prog_cc_static='-bnso -bI:/lib/syscalls.exp'
+      fi
+      ;;
+
+    hpux9* | hpux10* | hpux11*)
+      # Is there a better lt_cv_prog_cc_static that works with the bundled CC?
+      lt_cv_prog_cc_wl='-Wl,'
+      lt_cv_prog_cc_static="${lt_cv_prog_cc_wl}-a ${lt_cv_prog_cc_wl}archive"
+      lt_cv_prog_cc_pic='+Z'
+      ;;
+
+    irix5* | irix6* | nonstopux*)
+      lt_cv_prog_cc_wl='-Wl,'
+      lt_cv_prog_cc_static='-non_shared'
+      # PIC (with -KPIC) is the default.
+      ;;
+
+    cygwin* | mingw* | pw32* | os2*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      lt_cv_prog_cc_pic='-DDLL_EXPORT'
+      ;;
+
+    newsos6)
+      lt_cv_prog_cc_pic='-KPIC'
+      lt_cv_prog_cc_static='-Bstatic'
+      ;;
+
+    osf3* | osf4* | osf5*)
+      # All OSF/1 code is PIC.
+      lt_cv_prog_cc_wl='-Wl,'
+      lt_cv_prog_cc_static='-non_shared'
+      ;;
+
+    sco3.2v5*)
+      lt_cv_prog_cc_pic='-Kpic'
+      lt_cv_prog_cc_static='-dn'
+      lt_cv_prog_cc_shlib='-belf'
+      ;;
+
+    solaris*)
+      lt_cv_prog_cc_pic='-KPIC'
+      lt_cv_prog_cc_static='-Bstatic'
+      lt_cv_prog_cc_wl='-Wl,'
+      ;;
+
+    sunos4*)
+      lt_cv_prog_cc_pic='-PIC'
+      lt_cv_prog_cc_static='-Bstatic'
+      lt_cv_prog_cc_wl='-Qoption ld '
+      ;;
+
+    sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+      lt_cv_prog_cc_pic='-KPIC'
+      lt_cv_prog_cc_static='-Bstatic'
+      lt_cv_prog_cc_wl='-Wl,'
+      ;;
+
+    uts4*)
+      lt_cv_prog_cc_pic='-pic'
+      lt_cv_prog_cc_static='-Bstatic'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec ;then
+	lt_cv_prog_cc_pic='-Kconform_pic'
+	lt_cv_prog_cc_static='-Bstatic'
+      fi
+      ;;
+
+    *)
+      lt_cv_prog_cc_can_build_shared=no
+      ;;
+    esac
+  fi
+
+fi
+
+if test -z "$lt_cv_prog_cc_pic"; then
+  echo "$as_me:$LINENO: result: none" >&5
+echo "${ECHO_T}none" >&6
+else
+  echo "$as_me:$LINENO: result: $lt_cv_prog_cc_pic" >&5
+echo "${ECHO_T}$lt_cv_prog_cc_pic" >&6
+
+  # Check to make sure the pic_flag actually works.
+  echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_cv_prog_cc_pic works" >&5
+echo $ECHO_N "checking if $compiler PIC flag $lt_cv_prog_cc_pic works... $ECHO_C" >&6
+  if test "${lt_cv_prog_cc_pic_works+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+      save_CFLAGS="$CFLAGS"
+    CFLAGS="$CFLAGS $lt_cv_prog_cc_pic -DPIC"
+    cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+        case $host_os in
+      hpux9* | hpux10* | hpux11*)
+	# On HP-UX, both CC and GCC only warn that PIC is supported... then
+	# they create non-PIC objects.  So, if there were any warnings, we
+	# assume that PIC is not supported.
+	if test -s conftest.err; then
+	  lt_cv_prog_cc_pic_works=no
+	else
+	  lt_cv_prog_cc_pic_works=yes
+	fi
+	;;
+      *)
+	lt_cv_prog_cc_pic_works=yes
+	;;
+      esac
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+      lt_cv_prog_cc_pic_works=no
+
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+    CFLAGS="$save_CFLAGS"
+
+fi
+
+
+  if test "X$lt_cv_prog_cc_pic_works" = Xno; then
+    lt_cv_prog_cc_pic=
+    lt_cv_prog_cc_can_build_shared=no
+  else
+    lt_cv_prog_cc_pic=" $lt_cv_prog_cc_pic"
+  fi
+
+  echo "$as_me:$LINENO: result: $lt_cv_prog_cc_pic_works" >&5
+echo "${ECHO_T}$lt_cv_prog_cc_pic_works" >&6
+fi
+
+# Check for any special shared library compilation flags.
+if test -n "$lt_cv_prog_cc_shlib"; then
+  { echo "$as_me:$LINENO: WARNING: \`$CC' requires \`$lt_cv_prog_cc_shlib' to build shared libraries" >&5
+echo "$as_me: WARNING: \`$CC' requires \`$lt_cv_prog_cc_shlib' to build shared libraries" >&2;}
+  if echo "$old_CC $old_CFLAGS " | egrep -e "[ 	]$lt_cv_prog_cc_shlib[ 	]" >/dev/null; then :
+  else
+   { echo "$as_me:$LINENO: WARNING: add \`$lt_cv_prog_cc_shlib' to the CC or CFLAGS env variable and reconfigure" >&5
+echo "$as_me: WARNING: add \`$lt_cv_prog_cc_shlib' to the CC or CFLAGS env variable and reconfigure" >&2;}
+    lt_cv_prog_cc_can_build_shared=no
+  fi
+fi
+
+echo "$as_me:$LINENO: checking if $compiler static flag $lt_cv_prog_cc_static works" >&5
+echo $ECHO_N "checking if $compiler static flag $lt_cv_prog_cc_static works... $ECHO_C" >&6
+if test "${lt_cv_prog_cc_static_works+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+    lt_cv_prog_cc_static_works=no
+  save_LDFLAGS="$LDFLAGS"
+  LDFLAGS="$LDFLAGS $lt_cv_prog_cc_static"
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  lt_cv_prog_cc_static_works=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+  LDFLAGS="$save_LDFLAGS"
+
+fi
+
+
+# Belt *and* braces to stop my trousers falling down:
+test "X$lt_cv_prog_cc_static_works" = Xno && lt_cv_prog_cc_static=
+echo "$as_me:$LINENO: result: $lt_cv_prog_cc_static_works" >&5
+echo "${ECHO_T}$lt_cv_prog_cc_static_works" >&6
+
+pic_flag="$lt_cv_prog_cc_pic"
+special_shlib_compile_flags="$lt_cv_prog_cc_shlib"
+wl="$lt_cv_prog_cc_wl"
+link_static_flag="$lt_cv_prog_cc_static"
+no_builtin_flag="$lt_cv_prog_cc_no_builtin"
+can_build_shared="$lt_cv_prog_cc_can_build_shared"
+
+
+# Check to see if options -o and -c are simultaneously supported by compiler
+echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
+echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6
+if test "${lt_cv_compiler_c_o+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+$rm -r conftest 2>/dev/null
+mkdir conftest
+cd conftest
+echo "int some_variable = 0;" > conftest.$ac_ext
+mkdir out
+# According to Tom Tromey, Ian Lance Taylor reported there are C compilers
+# that will create temporary files in the current directory regardless of
+# the output directory.  Thus, making CWD read-only will cause this test
+# to fail, enabling locking or at least warning the user not to do parallel
+# builds.
+chmod -w .
+save_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -o out/conftest2.$ac_objext"
+compiler_c_o=no
+if { (eval echo configure:5134: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then
+  # The compiler can only warn and ignore the option if not recognized
+  # So say no if there are warnings
+  if test -s out/conftest.err; then
+    lt_cv_compiler_c_o=no
+  else
+    lt_cv_compiler_c_o=yes
+  fi
+else
+  # Append any errors to the config.log.
+  cat out/conftest.err 1>&5
+  lt_cv_compiler_c_o=no
+fi
+CFLAGS="$save_CFLAGS"
+chmod u+w .
+$rm conftest* out/*
+rmdir out
+cd ..
+rmdir conftest
+$rm -r conftest 2>/dev/null
+
+fi
+
+compiler_c_o=$lt_cv_compiler_c_o
+echo "$as_me:$LINENO: result: $compiler_c_o" >&5
+echo "${ECHO_T}$compiler_c_o" >&6
+
+if test x"$compiler_c_o" = x"yes"; then
+  # Check to see if we can write to a .lo
+  echo "$as_me:$LINENO: checking if $compiler supports -c -o file.lo" >&5
+echo $ECHO_N "checking if $compiler supports -c -o file.lo... $ECHO_C" >&6
+  if test "${lt_cv_compiler_o_lo+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+  lt_cv_compiler_o_lo=no
+  save_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -c -o conftest.lo"
+  save_objext="$ac_objext"
+  ac_objext=lo
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+int some_variable = 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+      # The compiler can only warn and ignore the option if not recognized
+    # So say no if there are warnings
+    if test -s conftest.err; then
+      lt_cv_compiler_o_lo=no
+    else
+      lt_cv_compiler_o_lo=yes
+    fi
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+  ac_objext="$save_objext"
+  CFLAGS="$save_CFLAGS"
+
+fi
+
+  compiler_o_lo=$lt_cv_compiler_o_lo
+  echo "$as_me:$LINENO: result: $compiler_o_lo" >&5
+echo "${ECHO_T}$compiler_o_lo" >&6
+else
+  compiler_o_lo=no
+fi
+
+# Check to see if we can do hard links to lock some files if needed
+hard_links="nottested"
+if test "$compiler_c_o" = no && test "$need_locks" != no; then
+  # do not overwrite the value of need_locks provided by the user
+  echo "$as_me:$LINENO: checking if we can lock with hard links" >&5
+echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6
+  hard_links=yes
+  $rm conftest*
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  touch conftest.a
+  ln conftest.a conftest.b 2>&5 || hard_links=no
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  echo "$as_me:$LINENO: result: $hard_links" >&5
+echo "${ECHO_T}$hard_links" >&6
+  if test "$hard_links" = no; then
+    { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
+echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
+    need_locks=warn
+  fi
+else
+  need_locks=no
+fi
+
+if test "$GCC" = yes; then
+  # Check to see if options -fno-rtti -fno-exceptions are supported by compiler
+  echo "$as_me:$LINENO: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
+echo $ECHO_N "checking if $compiler supports -fno-rtti -fno-exceptions... $ECHO_C" >&6
+  echo "int some_variable = 0;" > conftest.$ac_ext
+  save_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -fno-rtti -fno-exceptions -c conftest.$ac_ext"
+  compiler_rtti_exceptions=no
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+int some_variable = 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+      # The compiler can only warn and ignore the option if not recognized
+    # So say no if there are warnings
+    if test -s conftest.err; then
+      compiler_rtti_exceptions=no
+    else
+      compiler_rtti_exceptions=yes
+    fi
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+  CFLAGS="$save_CFLAGS"
+  echo "$as_me:$LINENO: result: $compiler_rtti_exceptions" >&5
+echo "${ECHO_T}$compiler_rtti_exceptions" >&6
+
+  if test "$compiler_rtti_exceptions" = "yes"; then
+    no_builtin_flag=' -fno-builtin -fno-rtti -fno-exceptions'
+  else
+    no_builtin_flag=' -fno-builtin'
+  fi
+fi
+
+# See if the linker supports building shared libraries.
+echo "$as_me:$LINENO: checking whether the linker ($LD) supports shared libraries" >&5
+echo $ECHO_N "checking whether the linker ($LD) supports shared libraries... $ECHO_C" >&6
+
+allow_undefined_flag=
+no_undefined_flag=
+need_lib_prefix=unknown
+need_version=unknown
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+archive_cmds=
+archive_expsym_cmds=
+old_archive_from_new_cmds=
+old_archive_from_expsyms_cmds=
+export_dynamic_flag_spec=
+whole_archive_flag_spec=
+thread_safe_flag_spec=
+hardcode_into_libs=no
+hardcode_libdir_flag_spec=
+hardcode_libdir_separator=
+hardcode_direct=no
+hardcode_minus_L=no
+hardcode_shlibpath_var=unsupported
+runpath_var=
+link_all_deplibs=unknown
+always_export_symbols=no
+export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | sed '\''s/.* //'\'' | sort | uniq > $export_symbols'
+# include_expsyms should be a list of space-separated symbols to be *always*
+# included in the symbol list
+include_expsyms=
+# exclude_expsyms can be an egrep regular expression of symbols to exclude
+# it will be wrapped by ` (' and `)$', so one must not match beginning or
+# end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+# as well as any symbol that contains `d'.
+exclude_expsyms="_GLOBAL_OFFSET_TABLE_"
+# Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+# platforms (ab)use it in PIC code, but their linkers get confused if
+# the symbol is explicitly referenced.  Since portable code cannot
+# rely on this symbol name, it's probably fine to never include it in
+# preloaded symbol tables.
+extract_expsyms_cmds=
+
+case $host_os in
+cygwin* | mingw* | pw32*)
+  # FIXME: the MSVC++ port hasn't been tested in a loooong time
+  # When not using gcc, we currently assume that we are using
+  # Microsoft Visual C++.
+  if test "$GCC" != yes; then
+    with_gnu_ld=no
+  fi
+  ;;
+openbsd*)
+  with_gnu_ld=no
+  ;;
+esac
+
+ld_shlibs=yes
+if test "$with_gnu_ld" = yes; then
+  # If archive_cmds runs LD, not CC, wlarc should be empty
+  wlarc='${wl}'
+
+  # See if GNU ld supports shared libraries.
+  case $host_os in
+  aix3* | aix4* | aix5*)
+    # On AIX, the GNU linker is very broken
+    # Note:Check GNU linker on AIX 5-IA64 when/if it becomes available.
+    ld_shlibs=no
+    cat <<EOF 1>&2
+
+*** Warning: the GNU linker, at least up to release 2.9.1, is reported
+*** to be unable to reliably create shared libraries on AIX.
+*** Therefore, libtool is disabling shared libraries support.  If you
+*** really care for shared libraries, you may want to modify your PATH
+*** so that a non-GNU linker is found, and then restart.
+
+EOF
+    ;;
+
+  amigaos*)
+    archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+    hardcode_libdir_flag_spec='-L$libdir'
+    hardcode_minus_L=yes
+
+    # Samuel A. Falvo II <kc5tja at dolphin.openprojects.net> reports
+    # that the semantics of dynamic libraries on AmigaOS, at least up
+    # to version 4, is to share data among multiple programs linked
+    # with the same dynamic library.  Since this doesn't match the
+    # behavior of shared libraries on other platforms, we can use
+    # them.
+    ld_shlibs=no
+    ;;
+
+  beos*)
+    if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
+      allow_undefined_flag=unsupported
+      # Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
+      # support --undefined.  This deserves some investigation.  FIXME
+      archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+    else
+      ld_shlibs=no
+    fi
+    ;;
+
+  cygwin* | mingw* | pw32*)
+    # hardcode_libdir_flag_spec is actually meaningless, as there is
+    # no search path for DLLs.
+    hardcode_libdir_flag_spec='-L$libdir'
+    allow_undefined_flag=unsupported
+    always_export_symbols=yes
+
+    extract_expsyms_cmds='test -f $output_objdir/impgen.c || \
+      sed -e "/^# \/\* impgen\.c starts here \*\//,/^# \/\* impgen.c ends here \*\// { s/^# //;s/^# *$//; p; }" -e d < $''0 > $output_objdir/impgen.c~
+      test -f $output_objdir/impgen.exe || (cd $output_objdir && \
+      if test "x$HOST_CC" != "x" ; then $HOST_CC -o impgen impgen.c ; \
+      else $CC -o impgen impgen.c ; fi)~
+      $output_objdir/impgen $dir/$soroot > $output_objdir/$soname-def'
+
+    old_archive_from_expsyms_cmds='$DLLTOOL --as=$AS --dllname $soname --def $output_objdir/$soname-def --output-lib $output_objdir/$newlib'
+
+    # cygwin and mingw dlls have different entry points and sets of symbols
+    # to exclude.
+    # FIXME: what about values for MSVC?
+    dll_entry=__cygwin_dll_entry at 12
+    dll_exclude_symbols=DllMain at 12,_cygwin_dll_entry at 12,_cygwin_noncygwin_dll_entry at 12~
+    case $host_os in
+    mingw*)
+      # mingw values
+      dll_entry=_DllMainCRTStartup at 12
+      dll_exclude_symbols=DllMain at 12,DllMainCRTStartup at 12,DllEntryPoint at 12~
+      ;;
+    esac
+
+    # mingw and cygwin differ, and it's simplest to just exclude the union
+    # of the two symbol sets.
+    dll_exclude_symbols=DllMain at 12,_cygwin_dll_entry at 12,_cygwin_noncygwin_dll_entry at 12,DllMainCRTStartup at 12,DllEntryPoint at 12
+
+    # recent cygwin and mingw systems supply a stub DllMain which the user
+    # can override, but on older systems we have to supply one (in ltdll.c)
+    if test "x$lt_cv_need_dllmain" = "xyes"; then
+      ltdll_obj='$output_objdir/$soname-ltdll.'"$ac_objext "
+      ltdll_cmds='test -f $output_objdir/$soname-ltdll.c || sed -e "/^# \/\* ltdll\.c starts here \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d < $''0 > $output_objdir/$soname-ltdll.c~
+	test -f $output_objdir/$soname-ltdll.$ac_objext || (cd $output_objdir && $CC -c $soname-ltdll.c)~'
+    else
+      ltdll_obj=
+      ltdll_cmds=
+    fi
+
+    # Extract the symbol export list from an `--export-all' def file,
+    # then regenerate the def file from the symbol export list, so that
+    # the compiled dll only exports the symbol export list.
+    # Be careful not to strip the DATA tag left be newer dlltools.
+    export_symbols_cmds="$ltdll_cmds"'
+      $DLLTOOL --export-all --exclude-symbols '$dll_exclude_symbols' --output-def $output_objdir/$soname-def '$ltdll_obj'$libobjs $convenience~
+      sed -e "1,/EXPORTS/d" -e "s/ @ [0-9]*//" -e "s/ *;.*$//" < $output_objdir/$soname-def > $export_symbols'
+
+    # If the export-symbols file already is a .def file (1st line
+    # is EXPORTS), use it as is.
+    # If DATA tags from a recent dlltool are present, honour them!
+    archive_expsym_cmds='if test "x`sed 1q $export_symbols`" = xEXPORTS; then
+	cp $export_symbols $output_objdir/$soname-def;
+      else
+	echo EXPORTS > $output_objdir/$soname-def;
+	_lt_hint=1;
+	cat $export_symbols | while read symbol; do
+	 set dummy \$symbol;
+	 case \$# in
+	   2) echo "   \$2 @ \$_lt_hint ; " >> $output_objdir/$soname-def;;
+	   4) echo "   \$2 \$3 \$4 ; " >> $output_objdir/$soname-def; _lt_hint=`expr \$_lt_hint - 1`;;
+	   *) echo "     \$2 @ \$_lt_hint \$3 ; " >> $output_objdir/$soname-def;;
+	 esac;
+	 _lt_hint=`expr 1 + \$_lt_hint`;
+	done;
+      fi~
+      '"$ltdll_cmds"'
+      $CC -Wl,--base-file,$output_objdir/$soname-base '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $output_objdir/$soname '$ltdll_obj'$libobjs $deplibs $compiler_flags~
+      $DLLTOOL --as=$AS --dllname $soname --exclude-symbols '$dll_exclude_symbols' --def $output_objdir/$soname-def --base-file $output_objdir/$soname-base --output-exp $output_objdir/$soname-exp~
+      $CC -Wl,--base-file,$output_objdir/$soname-base $output_objdir/$soname-exp '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $output_objdir/$soname '$ltdll_obj'$libobjs $deplibs $compiler_flags~
+      $DLLTOOL --as=$AS --dllname $soname --exclude-symbols '$dll_exclude_symbols' --def $output_objdir/$soname-def --base-file $output_objdir/$soname-base --output-exp $output_objdir/$soname-exp --output-lib $output_objdir/$libname.dll.a~
+      $CC $output_objdir/$soname-exp '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $output_objdir/$soname '$ltdll_obj'$libobjs $deplibs $compiler_flags'
+    ;;
+
+  netbsd*)
+    if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+      archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+      wlarc=
+    else
+      archive_cmds='$CC -shared -nodefaultlibs $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      archive_expsym_cmds='$CC -shared -nodefaultlibs $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+    fi
+    ;;
+
+  solaris* | sysv5*)
+    if $LD -v 2>&1 | egrep 'BFD 2\.8' > /dev/null; then
+      ld_shlibs=no
+      cat <<EOF 1>&2
+
+*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+*** create shared libraries on Solaris systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.9.1 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+EOF
+    elif $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
+      archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+    else
+      ld_shlibs=no
+    fi
+    ;;
+
+  sunos4*)
+    archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+    wlarc=
+    hardcode_direct=yes
+    hardcode_shlibpath_var=no
+    ;;
+
+  *)
+    if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
+      archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+    else
+      ld_shlibs=no
+    fi
+    ;;
+  esac
+
+  if test "$ld_shlibs" = yes; then
+    runpath_var=LD_RUN_PATH
+    hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir'
+    export_dynamic_flag_spec='${wl}--export-dynamic'
+    case $host_os in
+    cygwin* | mingw* | pw32*)
+      # dlltool doesn't understand --whole-archive et. al.
+      whole_archive_flag_spec=
+      ;;
+    *)
+      # ancient GNU ld didn't support --whole-archive et. al.
+      if $LD --help 2>&1 | egrep 'no-whole-archive' > /dev/null; then
+	whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      else
+	whole_archive_flag_spec=
+      fi
+      ;;
+    esac
+  fi
+else
+  # PORTME fill in a description of your system's linker (not GNU ld)
+  case $host_os in
+  aix3*)
+    allow_undefined_flag=unsupported
+    always_export_symbols=yes
+    archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+    # Note: this linker hardcodes the directories in LIBPATH if there
+    # are no directories specified by -L.
+    hardcode_minus_L=yes
+    if test "$GCC" = yes && test -z "$link_static_flag"; then
+      # Neither direct hardcoding nor static linking is supported with a
+      # broken collect2.
+      hardcode_direct=unsupported
+    fi
+    ;;
+
+  aix4* | aix5*)
+    if test "$host_cpu" = ia64; then
+      # On IA64, the linker does run time linking by default, so we don't
+      # have to do anything special.
+      aix_use_runtimelinking=no
+      exp_sym_flag='-Bexport'
+      no_entry_flag=""
+    else
+      aix_use_runtimelinking=no
+
+      # Test if we are trying to use run time linking or normal
+      # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+      # need to do runtime linking.
+      case $host_os in aix4.[23]|aix4.[23].*|aix5*)
+	for ld_flag in $LDFLAGS; do
+	  case $ld_flag in
+	  *-brtl*)
+	    aix_use_runtimelinking=yes
+	    break
+	  ;;
+	  esac
+	done
+      esac
+
+      exp_sym_flag='-bexport'
+      no_entry_flag='-bnoentry'
+    fi
+
+    # When large executables or shared objects are built, AIX ld can
+    # have problems creating the table of contents.  If linking a library
+    # or program results in "error TOC overflow" add -mminimal-toc to
+    # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
+    # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+    hardcode_direct=yes
+    archive_cmds=''
+    hardcode_libdir_separator=':'
+    if test "$GCC" = yes; then
+      case $host_os in aix4.[012]|aix4.[012].*)
+	collect2name=`${CC} -print-prog-name=collect2`
+	if test -f "$collect2name" && \
+	  strings "$collect2name" | grep resolve_lib_name >/dev/null
+	then
+	  # We have reworked collect2
+	  hardcode_direct=yes
+	else
+	  # We have old collect2
+	  hardcode_direct=unsupported
+	  # It fails to find uninstalled libraries when the uninstalled
+	  # path is not listed in the libpath.  Setting hardcode_minus_L
+	  # to unsupported forces relinking
+	  hardcode_minus_L=yes
+	  hardcode_libdir_flag_spec='-L$libdir'
+	  hardcode_libdir_separator=
+	fi
+      esac
+
+      shared_flag='-shared'
+    else
+      # not using gcc
+      if test "$host_cpu" = ia64; then
+	shared_flag='${wl}-G'
+      else
+	if test "$aix_use_runtimelinking" = yes; then
+	  shared_flag='${wl}-G'
+	else
+	  shared_flag='${wl}-bM:SRE'
+	fi
+      fi
+    fi
+
+    # It seems that -bexpall can do strange things, so it is better to
+    # generate a list of symbols to export.
+    always_export_symbols=yes
+    if test "$aix_use_runtimelinking" = yes; then
+      # Warning - without using the other runtime loading flags (-brtl),
+      # -berok will link without error, but may produce a broken library.
+      allow_undefined_flag='-berok'
+      hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:/usr/lib:/lib'
+      archive_expsym_cmds="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+    else
+      if test "$host_cpu" = ia64; then
+	hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
+	allow_undefined_flag="-z nodefs"
+	archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname ${wl}-h$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"
+      else
+	hardcode_libdir_flag_spec='${wl}-bnolibpath ${wl}-blibpath:$libdir:/usr/lib:/lib'
+	# Warning - without using the other run time loading flags,
+	# -berok will link without error, but may produce a broken library.
+	allow_undefined_flag='${wl}-berok'
+	# This is a bit strange, but is similar to how AIX traditionally builds
+	# it's shared libraries.
+	archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"' ~$AR -crlo $objdir/$libname$release.a $objdir/$soname'
+      fi
+    fi
+    ;;
+
+  amigaos*)
+    archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+    hardcode_libdir_flag_spec='-L$libdir'
+    hardcode_minus_L=yes
+    # see comment about different semantics on the GNU ld section
+    ld_shlibs=no
+    ;;
+
+  cygwin* | mingw* | pw32*)
+    # When not using gcc, we currently assume that we are using
+    # Microsoft Visual C++.
+    # hardcode_libdir_flag_spec is actually meaningless, as there is
+    # no search path for DLLs.
+    hardcode_libdir_flag_spec=' '
+    allow_undefined_flag=unsupported
+    # Tell ltmain to make .lib files, not .a files.
+    libext=lib
+    # FIXME: Setting linknames here is a bad hack.
+    archive_cmds='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | sed -e '\''s/ -lc$//'\''` -link -dll~linknames='
+    # The linker will automatically build a .lib file if we build a DLL.
+    old_archive_from_new_cmds='true'
+    # FIXME: Should let the user specify the lib program.
+    old_archive_cmds='lib /OUT:$oldlib$oldobjs$old_deplibs'
+    fix_srcfile_path='`cygpath -w "$srcfile"`'
+    ;;
+
+  darwin* | rhapsody*)
+    case "$host_os" in
+    rhapsody* | darwin1.[012])
+      allow_undefined_flag='-undefined suppress'
+      ;;
+    *) # Darwin 1.3 on
+      allow_undefined_flag='-flat_namespace -undefined suppress'
+      ;;
+    esac
+    # FIXME: Relying on posixy $() will cause problems for
+    #        cross-compilation, but unfortunately the echo tests do not
+    #        yet detect zsh echo's removal of \ escapes.  Also zsh mangles
+    #	     `"' quotes if we put them in here... so don't!
+    archive_cmds='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs && $CC $(test .$module = .yes && echo -bundle || echo -dynamiclib) $allow_undefined_flag -o $lib ${lib}-master.o $deplibs$linker_flags $(test .$module != .yes && echo -install_name $rpath/$soname $verstring)'
+    # We need to add '_' to the symbols in $export_symbols first
+    #archive_expsym_cmds="$archive_cmds"' && strip -s $export_symbols'
+    hardcode_direct=yes
+    hardcode_shlibpath_var=no
+    whole_archive_flag_spec='-all_load $convenience'
+    ;;
+
+  freebsd1*)
+    ld_shlibs=no
+    ;;
+
+  # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+  # support.  Future versions do this automatically, but an explicit c++rt0.o
+  # does not break anything, and helps significantly (at the cost of a little
+  # extra space).
+  freebsd2.2*)
+    archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+    hardcode_libdir_flag_spec='-R$libdir'
+    hardcode_direct=yes
+    hardcode_shlibpath_var=no
+    ;;
+
+  # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+  freebsd2*)
+    archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+    hardcode_direct=yes
+    hardcode_minus_L=yes
+    hardcode_shlibpath_var=no
+    ;;
+
+  # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+  freebsd*)
+    archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
+    hardcode_libdir_flag_spec='-R$libdir'
+    hardcode_direct=yes
+    hardcode_shlibpath_var=no
+    ;;
+
+  hpux9* | hpux10* | hpux11*)
+    case $host_os in
+    hpux9*) archive_cmds='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' ;;
+    *) archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' ;;
+    esac
+    hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+    hardcode_libdir_separator=:
+    hardcode_direct=yes
+    hardcode_minus_L=yes # Not in the search PATH, but as the default
+			 # location of the library.
+    export_dynamic_flag_spec='${wl}-E'
+    ;;
+
+  irix5* | irix6* | nonstopux*)
+    if test "$GCC" = yes; then
+      archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+    else
+      archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+      hardcode_libdir_flag_spec='-rpath $libdir'
+    fi
+    hardcode_libdir_separator=:
+    link_all_deplibs=yes
+    ;;
+
+  netbsd*)
+    if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+      archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
+    else
+      archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
+    fi
+    hardcode_libdir_flag_spec='-R$libdir'
+    hardcode_direct=yes
+    hardcode_shlibpath_var=no
+    ;;
+
+  newsos6)
+    archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+    hardcode_direct=yes
+    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+    hardcode_libdir_separator=:
+    hardcode_shlibpath_var=no
+    ;;
+
+  openbsd*)
+    hardcode_direct=yes
+    hardcode_shlibpath_var=no
+    if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+      archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+      hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+      export_dynamic_flag_spec='${wl}-E'
+    else
+      case "$host_os" in
+      openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
+	archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+	hardcode_libdir_flag_spec='-R$libdir'
+        ;;
+      *)
+        archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+        hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+        ;;
+      esac
+    fi
+    ;;
+
+  os2*)
+    hardcode_libdir_flag_spec='-L$libdir'
+    hardcode_minus_L=yes
+    allow_undefined_flag=unsupported
+    archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+    old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+    ;;
+
+  osf3*)
+    if test "$GCC" = yes; then
+      allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
+      archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+    else
+      allow_undefined_flag=' -expect_unresolved \*'
+      archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+    fi
+    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+    hardcode_libdir_separator=:
+    ;;
+
+  osf4* | osf5*)	# as osf3* with the addition of -msym flag
+    if test "$GCC" = yes; then
+      allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
+      archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+    else
+      allow_undefined_flag=' -expect_unresolved \*'
+      archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+      archive_expsym_cmds='for i in `cat $export_symbols`; do printf "-exported_symbol " >> $lib.exp; echo "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
+      $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib~$rm $lib.exp'
+
+      #Both c and cxx compiler support -rpath directly
+      hardcode_libdir_flag_spec='-rpath $libdir'
+    fi
+    hardcode_libdir_separator=:
+    ;;
+
+  sco3.2v5*)
+    archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+    hardcode_shlibpath_var=no
+    runpath_var=LD_RUN_PATH
+    hardcode_runpath_var=yes
+    export_dynamic_flag_spec='${wl}-Bexport'
+    ;;
+
+  solaris*)
+    # gcc --version < 3.0 without binutils cannot create self contained
+    # shared libraries reliably, requiring libgcc.a to resolve some of
+    # the object symbols generated in some cases.  Libraries that use
+    # assert need libgcc.a to resolve __eprintf, for example.  Linking
+    # a copy of libgcc.a into every shared library to guarantee resolving
+    # such symbols causes other problems:  According to Tim Van Holder
+    # <tim.van.holder at pandora.be>, C++ libraries end up with a separate
+    # (to the application) exception stack for one thing.
+    no_undefined_flag=' -z defs'
+    if test "$GCC" = yes; then
+      case `$CC --version 2>/dev/null` in
+      [12].*)
+	cat <<EOF 1>&2
+
+*** Warning: Releases of GCC earlier than version 3.0 cannot reliably
+*** create self contained shared libraries on Solaris systems, without
+*** introducing a dependency on libgcc.a.  Therefore, libtool is disabling
+*** -no-undefined support, which will at least allow you to build shared
+*** libraries.  However, you may find that when you link such libraries
+*** into an application without using GCC, you have to manually add
+*** \`gcc --print-libgcc-file-name\` to the link command.  We urge you to
+*** upgrade to a newer version of GCC.  Another option is to rebuild your
+*** current GCC to use the GNU linker from GNU binutils 2.9.1 or newer.
+
+EOF
+        no_undefined_flag=
+	;;
+      esac
+    fi
+    # $CC -shared without GNU ld will not create a library from C++
+    # object files and a static libstdc++, better avoid it by now
+    archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+    archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+		$LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
+    hardcode_libdir_flag_spec='-R$libdir'
+    hardcode_shlibpath_var=no
+    case $host_os in
+    solaris2.[0-5] | solaris2.[0-5].*) ;;
+    *) # Supported since Solaris 2.6 (maybe 2.5.1?)
+      whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;;
+    esac
+    link_all_deplibs=yes
+    ;;
+
+  sunos4*)
+    if test "x$host_vendor" = xsequent; then
+      # Use $CC to link under sequent, because it throws in some extra .o
+      # files that make .init and .fini sections work.
+      archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+    else
+      archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+    fi
+    hardcode_libdir_flag_spec='-L$libdir'
+    hardcode_direct=yes
+    hardcode_minus_L=yes
+    hardcode_shlibpath_var=no
+    ;;
+
+  sysv4)
+    case $host_vendor in
+      sni)
+        archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+        hardcode_direct=yes # is this really true???
+        ;;
+      siemens)
+        ## LD is ld it makes a PLAMLIB
+        ## CC just makes a GrossModule.
+        archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+        reload_cmds='$CC -r -o $output$reload_objs'
+        hardcode_direct=no
+        ;;
+      motorola)
+        archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+        hardcode_direct=no #Motorola manual says yes, but my tests say they lie
+        ;;
+    esac
+    runpath_var='LD_RUN_PATH'
+    hardcode_shlibpath_var=no
+    ;;
+
+  sysv4.3*)
+    archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+    hardcode_shlibpath_var=no
+    export_dynamic_flag_spec='-Bexport'
+    ;;
+
+  sysv5*)
+    no_undefined_flag=' -z text'
+    # $CC -shared without GNU ld will not create a library from C++
+    # object files and a static libstdc++, better avoid it by now
+    archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+    archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+		$LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
+    hardcode_libdir_flag_spec=
+    hardcode_shlibpath_var=no
+    runpath_var='LD_RUN_PATH'
+    ;;
+
+  uts4*)
+    archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+    hardcode_libdir_flag_spec='-L$libdir'
+    hardcode_shlibpath_var=no
+    ;;
+
+  dgux*)
+    archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+    hardcode_libdir_flag_spec='-L$libdir'
+    hardcode_shlibpath_var=no
+    ;;
+
+  sysv4*MP*)
+    if test -d /usr/nec; then
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_shlibpath_var=no
+      runpath_var=LD_RUN_PATH
+      hardcode_runpath_var=yes
+      ld_shlibs=yes
+    fi
+    ;;
+
+  sysv4.2uw2*)
+    archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+    hardcode_direct=yes
+    hardcode_minus_L=no
+    hardcode_shlibpath_var=no
+    hardcode_runpath_var=yes
+    runpath_var=LD_RUN_PATH
+    ;;
+
+  sysv5uw7* | unixware7*)
+    no_undefined_flag='${wl}-z ${wl}text'
+    if test "$GCC" = yes; then
+      archive_cmds='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+    else
+      archive_cmds='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+    fi
+    runpath_var='LD_RUN_PATH'
+    hardcode_shlibpath_var=no
+    ;;
+
+  *)
+    ld_shlibs=no
+    ;;
+  esac
+fi
+echo "$as_me:$LINENO: result: $ld_shlibs" >&5
+echo "${ECHO_T}$ld_shlibs" >&6
+test "$ld_shlibs" = no && can_build_shared=no
+
+# Check hardcoding attributes.
+echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5
+echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6
+hardcode_action=
+if test -n "$hardcode_libdir_flag_spec" || \
+   test -n "$runpath_var"; then
+
+  # We can hardcode non-existant directories.
+  if test "$hardcode_direct" != no &&
+     # If the only mechanism to avoid hardcoding is shlibpath_var, we
+     # have to relink, otherwise we might link with an installed library
+     # when we should be linking with a yet-to-be-installed one
+     ## test "$hardcode_shlibpath_var" != no &&
+     test "$hardcode_minus_L" != no; then
+    # Linking always hardcodes the temporary library directory.
+    hardcode_action=relink
+  else
+    # We can link without hardcoding, and we can hardcode nonexisting dirs.
+    hardcode_action=immediate
+  fi
+else
+  # We cannot hardcode anything, or else we can only hardcode existing
+  # directories.
+  hardcode_action=unsupported
+fi
+echo "$as_me:$LINENO: result: $hardcode_action" >&5
+echo "${ECHO_T}$hardcode_action" >&6
+
+striplib=
+old_striplib=
+echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5
+echo $ECHO_N "checking whether stripping libraries is possible... $ECHO_C" >&6
+if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then
+  test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+  test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+  echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+reload_cmds='$LD$reload_flag -o $output$reload_objs'
+test -z "$deplibs_check_method" && deplibs_check_method=unknown
+
+# PORTME Fill in your ld.so characteristics
+echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5
+echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+
+case $host_os in
+aix3*)
+  version_type=linux
+  library_names_spec='${libname}${release}.so$versuffix $libname.a'
+  shlibpath_var=LIBPATH
+
+  # AIX has no versioning support, so we append a major version to the name.
+  soname_spec='${libname}${release}.so$major'
+  ;;
+
+aix4* | aix5*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  hardcode_into_libs=yes
+  if test "$host_cpu" = ia64; then
+    # AIX 5 supports IA64
+    library_names_spec='${libname}${release}.so$major ${libname}${release}.so$versuffix $libname.so'
+    shlibpath_var=LD_LIBRARY_PATH
+  else
+    # With GCC up to 2.95.x, collect2 would create an import file
+    # for dependence libraries.  The import file would start with
+    # the line `#! .'.  This would cause the generated library to
+    # depend on `.', always an invalid library.  This was fixed in
+    # development snapshots of GCC prior to 3.0.
+    case $host_os in
+      aix4 | aix4.[01] | aix4.[01].*)
+	if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+	     echo ' yes '
+	     echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
+	  :
+	else
+	  can_build_shared=no
+	fi
+	;;
+    esac
+    # AIX (on Power*) has no versioning support, so currently we can
+    # not hardcode correct soname into executable. Probably we can
+    # add versioning support to collect2, so additional links can
+    # be useful in future.
+    if test "$aix_use_runtimelinking" = yes; then
+      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+      # instead of lib<name>.a to let people know that these are not
+      # typical AIX shared libraries.
+      library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+    else
+      # We preserve .a as extension for shared libraries through AIX4.2
+      # and later when we are not doing run time linking.
+      library_names_spec='${libname}${release}.a $libname.a'
+      soname_spec='${libname}${release}.so$major'
+    fi
+    shlibpath_var=LIBPATH
+  fi
+  hardcode_into_libs=yes
+  ;;
+
+amigaos*)
+  library_names_spec='$libname.ixlibrary $libname.a'
+  # Create ${libname}_ixlibrary.a entries in /sys/libs.
+  finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "(cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a)"; (cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a) || exit 1; done'
+  ;;
+
+beos*)
+  library_names_spec='${libname}.so'
+  dynamic_linker="$host_os ld.so"
+  shlibpath_var=LIBRARY_PATH
+  ;;
+
+bsdi4*)
+  version_type=linux
+  need_version=no
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+  soname_spec='${libname}${release}.so$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+  export_dynamic_flag_spec=-rdynamic
+  # the default ld.so.conf also contains /usr/contrib/lib and
+  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+  # libtool to hard-code these into programs
+  ;;
+
+cygwin* | mingw* | pw32*)
+  version_type=windows
+  need_version=no
+  need_lib_prefix=no
+  case $GCC,$host_os in
+  yes,cygwin*)
+    library_names_spec='$libname.dll.a'
+    soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll'
+    postinstall_cmds='dlpath=`bash 2>&1 -c '\''. $dir/${file}i;echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog .libs/$dlname \$dldir/$dlname'
+    postuninstall_cmds='dldll=`bash 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $rm \$dlpath'
+    ;;
+  yes,mingw*)
+    library_names_spec='${libname}`echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll'
+    sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | sed -e "s/^libraries://" -e "s/;/ /g" -e "s,=/,/,g"`
+    ;;
+  yes,pw32*)
+    library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | sed -e 's/./-/g'`${versuffix}.dll'
+    ;;
+  *)
+    library_names_spec='${libname}`echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll $libname.lib'
+    ;;
+  esac
+  dynamic_linker='Win32 ld.exe'
+  # FIXME: first we should search . and the directory the executable is in
+  shlibpath_var=PATH
+  ;;
+
+darwin* | rhapsody*)
+  dynamic_linker="$host_os dyld"
+  version_type=darwin
+  need_lib_prefix=no
+  need_version=no
+  # FIXME: Relying on posixy $() will cause problems for
+  #        cross-compilation, but unfortunately the echo tests do not
+  #        yet detect zsh echo's removal of \ escapes.
+  library_names_spec='${libname}${release}${versuffix}.$(test .$module = .yes && echo so || echo dylib) ${libname}${release}${major}.$(test .$module = .yes && echo so || echo dylib) ${libname}.$(test .$module = .yes && echo so || echo dylib)'
+  soname_spec='${libname}${release}${major}.$(test .$module = .yes && echo so || echo dylib)'
+  shlibpath_overrides_runpath=yes
+  shlibpath_var=DYLD_LIBRARY_PATH
+  ;;
+
+freebsd1*)
+  dynamic_linker=no
+  ;;
+
+freebsd*)
+  objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
+  version_type=freebsd-$objformat
+  case $version_type in
+    freebsd-elf*)
+      library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so'
+      need_version=no
+      need_lib_prefix=no
+      ;;
+    freebsd-*)
+      library_names_spec='${libname}${release}.so$versuffix $libname.so$versuffix'
+      need_version=yes
+      ;;
+  esac
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_os in
+  freebsd2*)
+    shlibpath_overrides_runpath=yes
+    ;;
+  *)
+    shlibpath_overrides_runpath=no
+    hardcode_into_libs=yes
+    ;;
+  esac
+  ;;
+
+gnu*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so${major} ${libname}.so'
+  soname_spec='${libname}${release}.so$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  hardcode_into_libs=yes
+  ;;
+
+hpux9* | hpux10* | hpux11*)
+  # Give a soname corresponding to the major version so that dld.sl refuses to
+  # link against other versions.
+  dynamic_linker="$host_os dld.sl"
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  shlibpath_var=SHLIB_PATH
+  shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+  library_names_spec='${libname}${release}.sl$versuffix ${libname}${release}.sl$major $libname.sl'
+  soname_spec='${libname}${release}.sl$major'
+  # HP-UX runs *really* slowly unless shared libraries are mode 555.
+  postinstall_cmds='chmod 555 $lib'
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $host_os in
+    nonstopux*) version_type=nonstopux ;;
+    *)          version_type=irix ;;
+  esac
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}.so$major'
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major ${libname}${release}.so $libname.so'
+  case $host_os in
+  irix5* | nonstopux*)
+    libsuff= shlibsuff=
+    ;;
+  *)
+    case $LD in # libtool.m4 will add one of these switches to LD
+    *-32|*"-32 ") libsuff= shlibsuff= libmagic=32-bit;;
+    *-n32|*"-n32 ") libsuff=32 shlibsuff=N32 libmagic=N32;;
+    *-64|*"-64 ") libsuff=64 shlibsuff=64 libmagic=64-bit;;
+    *) libsuff= shlibsuff= libmagic=never-match;;
+    esac
+    ;;
+  esac
+  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+  shlibpath_overrides_runpath=no
+  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  ;;
+
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+  dynamic_linker=no
+  ;;
+
+# This must be Linux ELF.
+linux*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+  soname_spec='${libname}${release}.so$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
+
+  case $host_cpu:$lt_cv_cc_64bit_output in
+  powerpc64:yes | s390x:yes | sparc64:yes | x86_64:yes)
+    sys_lib_dlsearch_path_spec="/lib64 /usr/lib64"
+    sys_lib_search_path_spec="/lib64 /usr/lib64 /usr/local/lib64"
+    ;;
+  esac
+
+  # We used to test for /lib/ld.so.1 and disable shared libraries on
+  # powerpc, because MkLinux only supported shared libraries with the
+  # GNU dynamic linker.  Since this was broken with cross compilers,
+  # most powerpc-linux boxes support dynamic linking these days and
+  # people can always --disable-shared, the test was removed, and we
+  # assume the GNU/Linux dynamic linker is in use.
+  dynamic_linker='GNU/Linux ld.so'
+  ;;
+
+netbsd*)
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+    library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix'
+    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+    dynamic_linker='NetBSD (a.out) ld.so'
+  else
+    library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major ${libname}${release}.so ${libname}.so'
+    soname_spec='${libname}${release}.so$major'
+    dynamic_linker='NetBSD ld.elf_so'
+  fi
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  ;;
+
+newsos6)
+  version_type=linux
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+openbsd*)
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    case "$host_os" in
+    openbsd2.[89] | openbsd2.[89].*)
+      shlibpath_overrides_runpath=no
+      ;;
+    *)
+      shlibpath_overrides_runpath=yes
+      ;;
+    esac
+  else
+    shlibpath_overrides_runpath=yes
+  fi
+  library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+os2*)
+  libname_spec='$name'
+  need_lib_prefix=no
+  library_names_spec='$libname.dll $libname.a'
+  dynamic_linker='OS/2 ld.exe'
+  shlibpath_var=LIBPATH
+  ;;
+
+osf3* | osf4* | osf5*)
+  version_type=osf
+  need_version=no
+  soname_spec='${libname}${release}.so$major'
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  hardcode_into_libs=yes
+  ;;
+
+sco3.2v5*)
+  version_type=osf
+  soname_spec='${libname}${release}.so$major'
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+solaris*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+  soname_spec='${libname}${release}.so$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  # ldd complains unless libraries are executable
+  postinstall_cmds='chmod +x $lib'
+  ;;
+
+sunos4*)
+  version_type=sunos
+  library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix'
+  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  if test "$with_gnu_ld" = yes; then
+    need_lib_prefix=no
+  fi
+  need_version=yes
+  ;;
+
+sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+  version_type=linux
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+  soname_spec='${libname}${release}.so$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_vendor in
+    sni)
+      shlibpath_overrides_runpath=no
+      need_lib_prefix=no
+      export_dynamic_flag_spec='${wl}-Blargedynsym'
+      runpath_var=LD_RUN_PATH
+      ;;
+    siemens)
+      need_lib_prefix=no
+      ;;
+    motorola)
+      need_lib_prefix=no
+      need_version=no
+      shlibpath_overrides_runpath=no
+      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+      ;;
+  esac
+  ;;
+
+uts4*)
+  version_type=linux
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+  soname_spec='${libname}${release}.so$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+dgux*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+  soname_spec='${libname}${release}.so$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+sysv4*MP*)
+  if test -d /usr/nec ;then
+    version_type=linux
+    library_names_spec='$libname.so.$versuffix $libname.so.$major $libname.so'
+    soname_spec='$libname.so.$major'
+    shlibpath_var=LD_LIBRARY_PATH
+  fi
+  ;;
+
+*)
+  dynamic_linker=no
+  ;;
+esac
+echo "$as_me:$LINENO: result: $dynamic_linker" >&5
+echo "${ECHO_T}$dynamic_linker" >&6
+test "$dynamic_linker" = no && can_build_shared=no
+
+# Report the final consequences.
+echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5
+echo $ECHO_N "checking if libtool supports shared libraries... $ECHO_C" >&6
+echo "$as_me:$LINENO: result: $can_build_shared" >&5
+echo "${ECHO_T}$can_build_shared" >&6
+
+echo "$as_me:$LINENO: checking whether to build shared libraries" >&5
+echo $ECHO_N "checking whether to build shared libraries... $ECHO_C" >&6
+test "$can_build_shared" = "no" && enable_shared=no
+
+# On AIX, shared libraries and static libraries use the same namespace, and
+# are all built from PIC.
+case "$host_os" in
+aix3*)
+  test "$enable_shared" = yes && enable_static=no
+  if test -n "$RANLIB"; then
+    archive_cmds="$archive_cmds~\$RANLIB \$lib"
+    postinstall_cmds='$RANLIB $lib'
+  fi
+  ;;
+
+aix4*)
+  if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+    test "$enable_shared" = yes && enable_static=no
+  fi
+  ;;
+esac
+echo "$as_me:$LINENO: result: $enable_shared" >&5
+echo "${ECHO_T}$enable_shared" >&6
+
+echo "$as_me:$LINENO: checking whether to build static libraries" >&5
+echo $ECHO_N "checking whether to build static libraries... $ECHO_C" >&6
+# Make sure either enable_shared or enable_static is yes.
+test "$enable_shared" = yes || enable_static=yes
+echo "$as_me:$LINENO: result: $enable_static" >&5
+echo "${ECHO_T}$enable_static" >&6
+
+if test "$hardcode_action" = relink; then
+  # Fast installation is not supported
+  enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+     test "$enable_shared" = no; then
+  # Fast installation is not necessary
+  enable_fast_install=needless
+fi
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+
+if test "x$enable_dlopen" != xyes; then
+  enable_dlopen=unknown
+  enable_dlopen_self=unknown
+  enable_dlopen_self_static=unknown
+else
+  lt_cv_dlopen=no
+  lt_cv_dlopen_libs=
+
+  case $host_os in
+  beos*)
+    lt_cv_dlopen="load_add_on"
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
+    ;;
+
+  cygwin* | mingw* | pw32*)
+    lt_cv_dlopen="LoadLibrary"
+    lt_cv_dlopen_libs=
+   ;;
+
+  *)
+    echo "$as_me:$LINENO: checking for shl_load" >&5
+echo $ECHO_N "checking for shl_load... $ECHO_C" >&6
+if test "${ac_cv_func_shl_load+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char shl_load (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char shl_load ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_shl_load) || defined (__stub___shl_load)
+choke me
+#else
+char (*f) () = shl_load;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != shl_load;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_shl_load=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_func_shl_load=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_func_shl_load" >&5
+echo "${ECHO_T}$ac_cv_func_shl_load" >&6
+if test $ac_cv_func_shl_load = yes; then
+  lt_cv_dlopen="shl_load"
+else
+  echo "$as_me:$LINENO: checking for shl_load in -ldld" >&5
+echo $ECHO_N "checking for shl_load in -ldld... $ECHO_C" >&6
+if test "${ac_cv_lib_dld_shl_load+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldld  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char shl_load ();
+int
+main ()
+{
+shl_load ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_dld_shl_load=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_dld_shl_load=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_dld_shl_load" >&5
+echo "${ECHO_T}$ac_cv_lib_dld_shl_load" >&6
+if test $ac_cv_lib_dld_shl_load = yes; then
+  lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"
+else
+  echo "$as_me:$LINENO: checking for dlopen" >&5
+echo $ECHO_N "checking for dlopen... $ECHO_C" >&6
+if test "${ac_cv_func_dlopen+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char dlopen (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char dlopen ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_dlopen) || defined (__stub___dlopen)
+choke me
+#else
+char (*f) () = dlopen;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != dlopen;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_dlopen=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_func_dlopen=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_func_dlopen" >&5
+echo "${ECHO_T}$ac_cv_func_dlopen" >&6
+if test $ac_cv_func_dlopen = yes; then
+  lt_cv_dlopen="dlopen"
+else
+  echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5
+echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6
+if test "${ac_cv_lib_dl_dlopen+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char dlopen ();
+int
+main ()
+{
+dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_dl_dlopen=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_dl_dlopen=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5
+echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6
+if test $ac_cv_lib_dl_dlopen = yes; then
+  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+else
+  echo "$as_me:$LINENO: checking for dlopen in -lsvld" >&5
+echo $ECHO_N "checking for dlopen in -lsvld... $ECHO_C" >&6
+if test "${ac_cv_lib_svld_dlopen+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lsvld  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char dlopen ();
+int
+main ()
+{
+dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_svld_dlopen=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_svld_dlopen=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_svld_dlopen" >&5
+echo "${ECHO_T}$ac_cv_lib_svld_dlopen" >&6
+if test $ac_cv_lib_svld_dlopen = yes; then
+  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"
+else
+  echo "$as_me:$LINENO: checking for dld_link in -ldld" >&5
+echo $ECHO_N "checking for dld_link in -ldld... $ECHO_C" >&6
+if test "${ac_cv_lib_dld_dld_link+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldld  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char dld_link ();
+int
+main ()
+{
+dld_link ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_dld_dld_link=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_dld_dld_link=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_dld_dld_link" >&5
+echo "${ECHO_T}$ac_cv_lib_dld_dld_link" >&6
+if test $ac_cv_lib_dld_dld_link = yes; then
+  lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+    ;;
+  esac
+
+  if test "x$lt_cv_dlopen" != xno; then
+    enable_dlopen=yes
+  else
+    enable_dlopen=no
+  fi
+
+  case $lt_cv_dlopen in
+  dlopen)
+    save_CPPFLAGS="$CPPFLAGS"
+        test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+
+    save_LDFLAGS="$LDFLAGS"
+    eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+
+    save_LIBS="$LIBS"
+    LIBS="$lt_cv_dlopen_libs $LIBS"
+
+    echo "$as_me:$LINENO: checking whether a program can dlopen itself" >&5
+echo $ECHO_N "checking whether a program can dlopen itself... $ECHO_C" >&6
+if test "${lt_cv_dlopen_self+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  	  if test "$cross_compiling" = yes; then :
+  lt_cv_dlopen_self=cross
+else
+    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+  lt_status=$lt_dlunknown
+  cat > conftest.$ac_ext <<EOF
+#line 6973 "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+#  define LT_DLGLOBAL		RTLD_GLOBAL
+#else
+#  ifdef DL_GLOBAL
+#    define LT_DLGLOBAL		DL_GLOBAL
+#  else
+#    define LT_DLGLOBAL		0
+#  endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+   find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+#  ifdef RTLD_LAZY
+#    define LT_DLLAZY_OR_NOW		RTLD_LAZY
+#  else
+#    ifdef DL_LAZY
+#      define LT_DLLAZY_OR_NOW		DL_LAZY
+#    else
+#      ifdef RTLD_NOW
+#        define LT_DLLAZY_OR_NOW	RTLD_NOW
+#      else
+#        ifdef DL_NOW
+#          define LT_DLLAZY_OR_NOW	DL_NOW
+#        else
+#          define LT_DLLAZY_OR_NOW	0
+#        endif
+#      endif
+#    endif
+#  endif
+#endif
+
+#ifdef __cplusplus
+extern "C" void exit (int);
+#endif
+
+void fnord() { int i=42;}
+int main ()
+{
+  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+  int status = $lt_dlunknown;
+
+  if (self)
+    {
+      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
+      else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+      /* dlclose (self); */
+    }
+
+    exit (status);
+}
+EOF
+  if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
+    (./conftest; exit; ) 2>/dev/null
+    lt_status=$?
+    case x$lt_status in
+      x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;
+      x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;;
+      x$lt_unknown|x*) lt_cv_dlopen_self=no ;;
+    esac
+  else :
+    # compilation failed
+    lt_cv_dlopen_self=no
+  fi
+fi
+rm -fr conftest*
+
+
+fi
+echo "$as_me:$LINENO: result: $lt_cv_dlopen_self" >&5
+echo "${ECHO_T}$lt_cv_dlopen_self" >&6
+
+    if test "x$lt_cv_dlopen_self" = xyes; then
+      LDFLAGS="$LDFLAGS $link_static_flag"
+      echo "$as_me:$LINENO: checking whether a statically linked program can dlopen itself" >&5
+echo $ECHO_N "checking whether a statically linked program can dlopen itself... $ECHO_C" >&6
+if test "${lt_cv_dlopen_self_static+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  	  if test "$cross_compiling" = yes; then :
+  lt_cv_dlopen_self_static=cross
+else
+    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+  lt_status=$lt_dlunknown
+  cat > conftest.$ac_ext <<EOF
+#line 7071 "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+#  define LT_DLGLOBAL		RTLD_GLOBAL
+#else
+#  ifdef DL_GLOBAL
+#    define LT_DLGLOBAL		DL_GLOBAL
+#  else
+#    define LT_DLGLOBAL		0
+#  endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+   find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+#  ifdef RTLD_LAZY
+#    define LT_DLLAZY_OR_NOW		RTLD_LAZY
+#  else
+#    ifdef DL_LAZY
+#      define LT_DLLAZY_OR_NOW		DL_LAZY
+#    else
+#      ifdef RTLD_NOW
+#        define LT_DLLAZY_OR_NOW	RTLD_NOW
+#      else
+#        ifdef DL_NOW
+#          define LT_DLLAZY_OR_NOW	DL_NOW
+#        else
+#          define LT_DLLAZY_OR_NOW	0
+#        endif
+#      endif
+#    endif
+#  endif
+#endif
+
+#ifdef __cplusplus
+extern "C" void exit (int);
+#endif
+
+void fnord() { int i=42;}
+int main ()
+{
+  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+  int status = $lt_dlunknown;
+
+  if (self)
+    {
+      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
+      else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+      /* dlclose (self); */
+    }
+
+    exit (status);
+}
+EOF
+  if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
+    (./conftest; exit; ) 2>/dev/null
+    lt_status=$?
+    case x$lt_status in
+      x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;
+      x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;;
+      x$lt_unknown|x*) lt_cv_dlopen_self_static=no ;;
+    esac
+  else :
+    # compilation failed
+    lt_cv_dlopen_self_static=no
+  fi
+fi
+rm -fr conftest*
+
+
+fi
+echo "$as_me:$LINENO: result: $lt_cv_dlopen_self_static" >&5
+echo "${ECHO_T}$lt_cv_dlopen_self_static" >&6
+    fi
+
+    CPPFLAGS="$save_CPPFLAGS"
+    LDFLAGS="$save_LDFLAGS"
+    LIBS="$save_LIBS"
+    ;;
+  esac
+
+  case $lt_cv_dlopen_self in
+  yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+  *) enable_dlopen_self=unknown ;;
+  esac
+
+  case $lt_cv_dlopen_self_static in
+  yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+  *) enable_dlopen_self_static=unknown ;;
+  esac
+fi
+
+
+if test "$enable_shared" = yes && test "$GCC" = yes; then
+  case $archive_cmds in
+  *'~'*)
+    # FIXME: we may have to deal with multi-command sequences.
+    ;;
+  '$CC '*)
+    # Test whether the compiler implicitly links with -lc since on some
+    # systems, -lgcc has to come before -lc. If gcc already passes -lc
+    # to ld, don't add -lc before -lgcc.
+    echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5
+echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6
+    if test "${lt_cv_archive_cmds_need_lc+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  $rm conftest*
+    echo 'static int dummy;' > conftest.$ac_ext
+
+    if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+      soname=conftest
+      lib=conftest
+      libobjs=conftest.$ac_objext
+      deplibs=
+      wl=$lt_cv_prog_cc_wl
+      compiler_flags=-v
+      linker_flags=-v
+      verstring=
+      output_objdir=.
+      libname=conftest
+      save_allow_undefined_flag=$allow_undefined_flag
+      allow_undefined_flag=
+      if { (eval echo "$as_me:$LINENO: \"$archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5
+  (eval $archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+      then
+	lt_cv_archive_cmds_need_lc=no
+      else
+	lt_cv_archive_cmds_need_lc=yes
+      fi
+      allow_undefined_flag=$save_allow_undefined_flag
+    else
+      cat conftest.err 1>&5
+    fi
+fi
+
+    echo "$as_me:$LINENO: result: $lt_cv_archive_cmds_need_lc" >&5
+echo "${ECHO_T}$lt_cv_archive_cmds_need_lc" >&6
+    ;;
+  esac
+fi
+need_lc=${lt_cv_archive_cmds_need_lc-yes}
+
+# The second clause should only fire when bootstrapping the
+# libtool distribution, otherwise you forgot to ship ltmain.sh
+# with your package, and you will get complaints that there are
+# no rules to generate ltmain.sh.
+if test -f "$ltmain"; then
+  :
+else
+  # If there is no Makefile yet, we rely on a make rule to execute
+  # `config.status --recheck' to rerun these tests and create the
+  # libtool script then.
+  test -f Makefile && make "$ltmain"
+fi
+
+if test -f "$ltmain"; then
+  trap "$rm \"${ofile}T\"; exit 1" 1 2 15
+  $rm -f "${ofile}T"
+
+  echo creating $ofile
+
+  # Now quote all the things that may contain metacharacters while being
+  # careful not to overquote the AC_SUBSTed values.  We take copies of the
+  # variables and quote the copies for generation of the libtool script.
+  for var in echo old_CC old_CFLAGS SED \
+    AR AR_FLAGS CC LD LN_S NM SHELL \
+    reload_flag reload_cmds wl \
+    pic_flag link_static_flag no_builtin_flag export_dynamic_flag_spec \
+    thread_safe_flag_spec whole_archive_flag_spec libname_spec \
+    library_names_spec soname_spec \
+    RANLIB old_archive_cmds old_archive_from_new_cmds old_postinstall_cmds \
+    old_postuninstall_cmds archive_cmds archive_expsym_cmds postinstall_cmds \
+    postuninstall_cmds extract_expsyms_cmds old_archive_from_expsyms_cmds \
+    old_striplib striplib file_magic_cmd export_symbols_cmds \
+    deplibs_check_method allow_undefined_flag no_undefined_flag \
+    finish_cmds finish_eval global_symbol_pipe global_symbol_to_cdecl \
+    global_symbol_to_c_name_address \
+    hardcode_libdir_flag_spec hardcode_libdir_separator  \
+    sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
+    compiler_c_o compiler_o_lo need_locks exclude_expsyms include_expsyms; do
+
+    case $var in
+    reload_cmds | old_archive_cmds | old_archive_from_new_cmds | \
+    old_postinstall_cmds | old_postuninstall_cmds | \
+    export_symbols_cmds | archive_cmds | archive_expsym_cmds | \
+    extract_expsyms_cmds | old_archive_from_expsyms_cmds | \
+    postinstall_cmds | postuninstall_cmds | \
+    finish_cmds | sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
+      # Double-quote double-evaled strings.
+      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
+      ;;
+    *)
+      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
+      ;;
+    esac
+  done
+
+  cat <<__EOF__ > "${ofile}T"
+#! $SHELL
+
+# `$echo "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
+# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP)
+# NOTE: Changes made to this file will be lost: look at ltmain.sh.
+#
+# Copyright (C) 1996-2000 Free Software Foundation, Inc.
+# Originally by Gordon Matzigkeit <gord at gnu.ai.mit.edu>, 1996
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# A sed that does not truncate output.
+SED=$lt_SED
+
+# Sed that helps us avoid accidentally triggering echo(1) options like -n.
+Xsed="${SED} -e s/^X//"
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+if test "X\${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi
+
+# ### BEGIN LIBTOOL CONFIG
+
+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+
+# Shell to use when invoking shell scripts.
+SHELL=$lt_SHELL
+
+# Whether or not to build shared libraries.
+build_libtool_libs=$enable_shared
+
+# Whether or not to build static libraries.
+build_old_libs=$enable_static
+
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$need_lc
+
+# Whether or not to optimize for fast installation.
+fast_install=$enable_fast_install
+
+# The host system.
+host_alias=$host_alias
+host=$host
+
+# An echo program that does not interpret backslashes.
+echo=$lt_echo
+
+# The archiver.
+AR=$lt_AR
+AR_FLAGS=$lt_AR_FLAGS
+
+# The default C compiler.
+CC=$lt_CC
+
+# Is the compiler the GNU C compiler?
+with_gcc=$GCC
+
+# The linker used to build libraries.
+LD=$lt_LD
+
+# Whether we need hard or soft links.
+LN_S=$lt_LN_S
+
+# A BSD-compatible nm program.
+NM=$lt_NM
+
+# A symbol stripping program
+STRIP=$STRIP
+
+# Used to examine libraries when file_magic_cmd begins "file"
+MAGIC_CMD=$MAGIC_CMD
+
+# Used on cygwin: DLL creation program.
+DLLTOOL="$DLLTOOL"
+
+# Used on cygwin: object dumper.
+OBJDUMP="$OBJDUMP"
+
+# Used on cygwin: assembler.
+AS=$lt_AS
+
+# The name of the directory that contains temporary libtool files.
+objdir=$objdir
+
+# How to create reloadable object files.
+reload_flag=$lt_reload_flag
+reload_cmds=$lt_reload_cmds
+
+# How to pass a linker flag through the compiler.
+wl=$lt_wl
+
+# Object file suffix (normally "o").
+objext="$ac_objext"
+
+# Old archive suffix (normally "a").
+libext="$libext"
+
+# Executable file suffix (normally "").
+exeext="$exeext"
+
+# Additional compiler flags for building library objects.
+pic_flag=$lt_pic_flag
+pic_mode=$pic_mode
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_compiler_c_o
+
+# Can we write directly to a .lo ?
+compiler_o_lo=$lt_compiler_o_lo
+
+# Must we lock files when doing compilation ?
+need_locks=$lt_need_locks
+
+# Do we need the lib prefix for modules?
+need_lib_prefix=$need_lib_prefix
+
+# Do we need a version for libraries?
+need_version=$need_version
+
+# Whether dlopen is supported.
+dlopen_support=$enable_dlopen
+
+# Whether dlopen of programs is supported.
+dlopen_self=$enable_dlopen_self
+
+# Whether dlopen of statically linked programs is supported.
+dlopen_self_static=$enable_dlopen_self_static
+
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$lt_link_static_flag
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_no_builtin_flag
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_whole_archive_flag_spec
+
+# Compiler flag to generate thread-safe objects.
+thread_safe_flag_spec=$lt_thread_safe_flag_spec
+
+# Library versioning type.
+version_type=$version_type
+
+# Format of library name prefix.
+libname_spec=$lt_libname_spec
+
+# List of archive names.  First name is the real one, the rest are links.
+# The last name is the one that the linker finds with -lNAME.
+library_names_spec=$lt_library_names_spec
+
+# The coded name of the library, if different from the real name.
+soname_spec=$lt_soname_spec
+
+# Commands used to build and install an old-style archive.
+RANLIB=$lt_RANLIB
+old_archive_cmds=$lt_old_archive_cmds
+old_postinstall_cmds=$lt_old_postinstall_cmds
+old_postuninstall_cmds=$lt_old_postuninstall_cmds
+
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds
+
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds
+
+# Commands used to build and install a shared archive.
+archive_cmds=$lt_archive_cmds
+archive_expsym_cmds=$lt_archive_expsym_cmds
+postinstall_cmds=$lt_postinstall_cmds
+postuninstall_cmds=$lt_postuninstall_cmds
+
+# Commands to strip libraries.
+old_striplib=$lt_old_striplib
+striplib=$lt_striplib
+
+# Method to check whether dependent libraries are shared objects.
+deplibs_check_method=$lt_deplibs_check_method
+
+# Command to use when deplibs_check_method == file_magic.
+file_magic_cmd=$lt_file_magic_cmd
+
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$lt_allow_undefined_flag
+
+# Flag that forces no undefined symbols.
+no_undefined_flag=$lt_no_undefined_flag
+
+# Commands used to finish a libtool library installation in a directory.
+finish_cmds=$lt_finish_cmds
+
+# Same as above, but a single script fragment to be evaled but not shown.
+finish_eval=$lt_finish_eval
+
+# Take the output of nm and produce a listing of raw symbols and C names.
+global_symbol_pipe=$lt_global_symbol_pipe
+
+# Transform the output of nm in a proper C declaration
+global_symbol_to_cdecl=$lt_global_symbol_to_cdecl
+
+# Transform the output of nm in a C name address pair
+global_symbol_to_c_name_address=$lt_global_symbol_to_c_name_address
+
+# This is the shared library runtime path variable.
+runpath_var=$runpath_var
+
+# This is the shared library path variable.
+shlibpath_var=$shlibpath_var
+
+# Is shlibpath searched before the hard-coded library search path?
+shlibpath_overrides_runpath=$shlibpath_overrides_runpath
+
+# How to hardcode a shared library path into an executable.
+hardcode_action=$hardcode_action
+
+# Whether we should hardcode library paths into libraries.
+hardcode_into_libs=$hardcode_into_libs
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist.
+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec
+
+# Whether we need a single -rpath flag with a separated argument.
+hardcode_libdir_separator=$lt_hardcode_libdir_separator
+
+# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the
+# resulting binary.
+hardcode_direct=$hardcode_direct
+
+# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
+# resulting binary.
+hardcode_minus_L=$hardcode_minus_L
+
+# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
+# the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var
+
+# Variables whose values should be saved in libtool wrapper scripts and
+# restored at relink time.
+variables_saved_for_relink="$variables_saved_for_relink"
+
+# Whether libtool must link a program against all its dependency libraries.
+link_all_deplibs=$link_all_deplibs
+
+# Compile-time system search path for libraries
+sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
+
+# Run-time system search path for libraries
+sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
+
+# Fix the shell variable \$srcfile for the compiler.
+fix_srcfile_path="$fix_srcfile_path"
+
+# Set to yes if exported symbols are required.
+always_export_symbols=$always_export_symbols
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_export_symbols_cmds
+
+# The commands to extract the exported symbol list from a shared archive.
+extract_expsyms_cmds=$lt_extract_expsyms_cmds
+
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$lt_exclude_expsyms
+
+# Symbols that must always be exported.
+include_expsyms=$lt_include_expsyms
+
+# ### END LIBTOOL CONFIG
+
+__EOF__
+
+  case $host_os in
+  aix3*)
+    cat <<\EOF >> "${ofile}T"
+
+# AIX sometimes has problems with the GCC collect2 program.  For some
+# reason, if we set the COLLECT_NAMES environment variable, the problems
+# vanish in a puff of smoke.
+if test "X${COLLECT_NAMES+set}" != Xset; then
+  COLLECT_NAMES=
+  export COLLECT_NAMES
+fi
+EOF
+    ;;
+  esac
+
+  case $host_os in
+  cygwin* | mingw* | pw32* | os2*)
+    cat <<'EOF' >> "${ofile}T"
+      # This is a source program that is used to create dlls on Windows
+      # Don't remove nor modify the starting and closing comments
+# /* ltdll.c starts here */
+# #define WIN32_LEAN_AND_MEAN
+# #include <windows.h>
+# #undef WIN32_LEAN_AND_MEAN
+# #include <stdio.h>
+#
+# #ifndef __CYGWIN__
+# #  ifdef __CYGWIN32__
+# #    define __CYGWIN__ __CYGWIN32__
+# #  endif
+# #endif
+#
+# #ifdef __cplusplus
+# extern "C" {
+# #endif
+# BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved);
+# #ifdef __cplusplus
+# }
+# #endif
+#
+# #ifdef __CYGWIN__
+# #include <cygwin/cygwin_dll.h>
+# DECLARE_CYGWIN_DLL( DllMain );
+# #endif
+# HINSTANCE __hDllInstance_base;
+#
+# BOOL APIENTRY
+# DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved)
+# {
+#   __hDllInstance_base = hInst;
+#   return TRUE;
+# }
+# /* ltdll.c ends here */
+	# This is a source program that is used to create import libraries
+	# on Windows for dlls which lack them. Don't remove nor modify the
+	# starting and closing comments
+# /* impgen.c starts here */
+# /*   Copyright (C) 1999-2000 Free Software Foundation, Inc.
+#
+#  This file is part of GNU libtool.
+#
+#  This program is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software
+#  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#  */
+#
+# #include <stdio.h>		/* for printf() */
+# #include <unistd.h>		/* for open(), lseek(), read() */
+# #include <fcntl.h>		/* for O_RDONLY, O_BINARY */
+# #include <string.h>		/* for strdup() */
+#
+# /* O_BINARY isn't required (or even defined sometimes) under Unix */
+# #ifndef O_BINARY
+# #define O_BINARY 0
+# #endif
+#
+# static unsigned int
+# pe_get16 (fd, offset)
+#      int fd;
+#      int offset;
+# {
+#   unsigned char b[2];
+#   lseek (fd, offset, SEEK_SET);
+#   read (fd, b, 2);
+#   return b[0] + (b[1]<<8);
+# }
+#
+# static unsigned int
+# pe_get32 (fd, offset)
+#     int fd;
+#     int offset;
+# {
+#   unsigned char b[4];
+#   lseek (fd, offset, SEEK_SET);
+#   read (fd, b, 4);
+#   return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24);
+# }
+#
+# static unsigned int
+# pe_as32 (ptr)
+#      void *ptr;
+# {
+#   unsigned char *b = ptr;
+#   return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24);
+# }
+#
+# int
+# main (argc, argv)
+#     int argc;
+#     char *argv[];
+# {
+#     int dll;
+#     unsigned long pe_header_offset, opthdr_ofs, num_entries, i;
+#     unsigned long export_rva, export_size, nsections, secptr, expptr;
+#     unsigned long name_rvas, nexp;
+#     unsigned char *expdata, *erva;
+#     char *filename, *dll_name;
+#
+#     filename = argv[1];
+#
+#     dll = open(filename, O_RDONLY|O_BINARY);
+#     if (dll < 1)
+# 	return 1;
+#
+#     dll_name = filename;
+#
+#     for (i=0; filename[i]; i++)
+# 	if (filename[i] == '/' || filename[i] == '\\'  || filename[i] == ':')
+# 	    dll_name = filename + i +1;
+#
+#     pe_header_offset = pe_get32 (dll, 0x3c);
+#     opthdr_ofs = pe_header_offset + 4 + 20;
+#     num_entries = pe_get32 (dll, opthdr_ofs + 92);
+#
+#     if (num_entries < 1) /* no exports */
+# 	return 1;
+#
+#     export_rva = pe_get32 (dll, opthdr_ofs + 96);
+#     export_size = pe_get32 (dll, opthdr_ofs + 100);
+#     nsections = pe_get16 (dll, pe_header_offset + 4 +2);
+#     secptr = (pe_header_offset + 4 + 20 +
+# 	      pe_get16 (dll, pe_header_offset + 4 + 16));
+#
+#     expptr = 0;
+#     for (i = 0; i < nsections; i++)
+#     {
+# 	char sname[8];
+# 	unsigned long secptr1 = secptr + 40 * i;
+# 	unsigned long vaddr = pe_get32 (dll, secptr1 + 12);
+# 	unsigned long vsize = pe_get32 (dll, secptr1 + 16);
+# 	unsigned long fptr = pe_get32 (dll, secptr1 + 20);
+# 	lseek(dll, secptr1, SEEK_SET);
+# 	read(dll, sname, 8);
+# 	if (vaddr <= export_rva && vaddr+vsize > export_rva)
+# 	{
+# 	    expptr = fptr + (export_rva - vaddr);
+# 	    if (export_rva + export_size > vaddr + vsize)
+# 		export_size = vsize - (export_rva - vaddr);
+# 	    break;
+# 	}
+#     }
+#
+#     expdata = (unsigned char*)malloc(export_size);
+#     lseek (dll, expptr, SEEK_SET);
+#     read (dll, expdata, export_size);
+#     erva = expdata - export_rva;
+#
+#     nexp = pe_as32 (expdata+24);
+#     name_rvas = pe_as32 (expdata+32);
+#
+#     printf ("EXPORTS\n");
+#     for (i = 0; i<nexp; i++)
+#     {
+# 	unsigned long name_rva = pe_as32 (erva+name_rvas+i*4);
+# 	printf ("\t%s @ %ld ;\n", erva+name_rva, 1+ i);
+#     }
+#
+#     return 0;
+# }
+# /* impgen.c ends here */
+
+EOF
+    ;;
+  esac
+
+  # We use sed instead of cat because bash on DJGPP gets confused if
+  # if finds mixed CR/LF and LF-only lines.  Since sed operates in
+  # text mode, it properly converts lines to CR/LF.  This bash problem
+  # is reportedly fixed, but why not run on old versions too?
+  sed '$q' "$ltmain" >> "${ofile}T" || (rm -f "${ofile}T"; exit 1)
+
+  mv -f "${ofile}T" "$ofile" || \
+    (rm -f "$ofile" && cp "${ofile}T" "$ofile" && rm -f "${ofile}T")
+  chmod +x "$ofile"
+fi
+
+
+
+
+
+# This can be used to rebuild libtool when needed
+LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh"
+
+# Always use our own libtool.
+LIBTOOL='$(SHELL) $(top_builddir)/libtool'
+
+# Prevent multiple expansion
+
+
+
+
+echo "$as_me:$LINENO: checking for ANSI C header files" >&5
+echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
+if test "${ac_cv_header_stdc+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_header_stdc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_header_stdc=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "memchr" >/dev/null 2>&1; then
+  :
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "free" >/dev/null 2>&1; then
+  :
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+  if test "$cross_compiling" = yes; then
+  :
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <ctype.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+                   (('a' <= (c) && (c) <= 'i') \
+                     || ('j' <= (c) && (c) <= 'r') \
+                     || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+  int i;
+  for (i = 0; i < 256; i++)
+    if (XOR (islower (i), ISLOWER (i))
+        || toupper (i) != TOUPPER (i))
+      exit(2);
+  exit (0);
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  :
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_header_stdc=no
+fi
+rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
+echo "${ECHO_T}$ac_cv_header_stdc" >&6
+if test $ac_cv_header_stdc = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define STDC_HEADERS 1
+_ACEOF
+
+fi
+
+echo "$as_me:$LINENO: checking for sys/wait.h that is POSIX.1 compatible" >&5
+echo $ECHO_N "checking for sys/wait.h that is POSIX.1 compatible... $ECHO_C" >&6
+if test "${ac_cv_header_sys_wait_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <sys/types.h>
+#include <sys/wait.h>
+#ifndef WEXITSTATUS
+# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
+#endif
+#ifndef WIFEXITED
+# define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
+#endif
+
+int
+main ()
+{
+  int s;
+  wait (&s);
+  s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_header_sys_wait_h=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_header_sys_wait_h=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_header_sys_wait_h" >&5
+echo "${ECHO_T}$ac_cv_header_sys_wait_h" >&6
+if test $ac_cv_header_sys_wait_h = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_SYS_WAIT_H 1
+_ACEOF
+
+fi
+
+
+for ac_header in sys/time.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+else
+  # Is the header compilable?
+echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_header_compiler=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc in
+  yes:no )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    (
+      cat <<\_ASBOX
+## ------------------------------------ ##
+## Report this to bug-autoconf at gnu.org. ##
+## ------------------------------------ ##
+_ASBOX
+    ) |
+      sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+  no:yes )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    (
+      cat <<\_ASBOX
+## ------------------------------------ ##
+## Report this to bug-autoconf at gnu.org. ##
+## ------------------------------------ ##
+_ASBOX
+    ) |
+      sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=$ac_header_preproc"
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+if test "$ac_cv_header_sys_time_h" = "yes"; then
+	echo "$as_me:$LINENO: checking whether time.h and sys/time.h may both be included" >&5
+echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6
+if test "${ac_cv_header_time+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <sys/types.h>
+#include <sys/time.h>
+#include <time.h>
+
+int
+main ()
+{
+if ((struct tm *) 0)
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_header_time=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_header_time=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_header_time" >&5
+echo "${ECHO_T}$ac_cv_header_time" >&6
+if test $ac_cv_header_time = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define TIME_WITH_SYS_TIME 1
+_ACEOF
+
+fi
+
+fi
+echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5
+echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6
+if test "${ac_cv_c_const+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+/* FIXME: Include the comments suggested by Paul. */
+#ifndef __cplusplus
+  /* Ultrix mips cc rejects this.  */
+  typedef int charset[2];
+  const charset x;
+  /* SunOS 4.1.1 cc rejects this.  */
+  char const *const *ccp;
+  char **p;
+  /* NEC SVR4.0.2 mips cc rejects this.  */
+  struct point {int x, y;};
+  static struct point const zero = {0,0};
+  /* AIX XL C 1.02.0.0 rejects this.
+     It does not let you subtract one const X* pointer from another in
+     an arm of an if-expression whose if-part is not a constant
+     expression */
+  const char *g = "string";
+  ccp = &g + (g ? g-g : 0);
+  /* HPUX 7.0 cc rejects these. */
+  ++ccp;
+  p = (char**) ccp;
+  ccp = (char const *const *) p;
+  { /* SCO 3.2v4 cc rejects this.  */
+    char *t;
+    char const *s = 0 ? (char *) 0 : (char const *) 0;
+
+    *t++ = 0;
+  }
+  { /* Someone thinks the Sun supposedly-ANSI compiler will reject this.  */
+    int x[] = {25, 17};
+    const int *foo = &x[0];
+    ++foo;
+  }
+  { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
+    typedef const int *iptr;
+    iptr p = 0;
+    ++p;
+  }
+  { /* AIX XL C 1.02.0.0 rejects this saying
+       "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
+    struct s { int j; const int *ap[3]; };
+    struct s *b; b->j = 5;
+  }
+  { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
+    const int foo = 10;
+  }
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_c_const=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_c_const=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5
+echo "${ECHO_T}$ac_cv_c_const" >&6
+if test $ac_cv_c_const = no; then
+
+cat >>confdefs.h <<\_ACEOF
+#define const
+_ACEOF
+
+fi
+
+echo "$as_me:$LINENO: checking for size_t" >&5
+echo $ECHO_N "checking for size_t... $ECHO_C" >&6
+if test "${ac_cv_type_size_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+if ((size_t *) 0)
+  return 0;
+if (sizeof (size_t))
+  return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_type_size_t=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_type_size_t=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5
+echo "${ECHO_T}$ac_cv_type_size_t" >&6
+if test $ac_cv_type_size_t = yes; then
+  :
+else
+
+cat >>confdefs.h <<_ACEOF
+#define size_t unsigned
+_ACEOF
+
+fi
+
+
+
+
+for ac_header in stropts.h sys/filio.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+else
+  # Is the header compilable?
+echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_header_compiler=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc in
+  yes:no )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    (
+      cat <<\_ASBOX
+## ------------------------------------ ##
+## Report this to bug-autoconf at gnu.org. ##
+## ------------------------------------ ##
+_ASBOX
+    ) |
+      sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+  no:yes )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    (
+      cat <<\_ASBOX
+## ------------------------------------ ##
+## Report this to bug-autoconf at gnu.org. ##
+## ------------------------------------ ##
+_ASBOX
+    ) |
+      sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=$ac_header_preproc"
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+
+for ac_header in stdint.h inttypes.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+else
+  # Is the header compilable?
+echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_header_compiler=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc in
+  yes:no )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    (
+      cat <<\_ASBOX
+## ------------------------------------ ##
+## Report this to bug-autoconf at gnu.org. ##
+## ------------------------------------ ##
+_ASBOX
+    ) |
+      sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+  no:yes )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    (
+      cat <<\_ASBOX
+## ------------------------------------ ##
+## Report this to bug-autoconf at gnu.org. ##
+## ------------------------------------ ##
+_ASBOX
+    ) |
+      sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=$ac_header_preproc"
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+###############################################################################
+# Check for standard size types.  The defaults are only valid on some
+# systems so we hope that <inttypes.h> exists when they're wrong.
+echo "$as_me:$LINENO: checking for int8_t" >&5
+echo $ECHO_N "checking for int8_t... $ECHO_C" >&6
+if test "${ac_cv_type_int8_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+if ((int8_t *) 0)
+  return 0;
+if (sizeof (int8_t))
+  return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_type_int8_t=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_type_int8_t=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_type_int8_t" >&5
+echo "${ECHO_T}$ac_cv_type_int8_t" >&6
+if test $ac_cv_type_int8_t = yes; then
+  :
+else
+
+cat >>confdefs.h <<_ACEOF
+#define int8_t signed char
+_ACEOF
+
+fi
+
+echo "$as_me:$LINENO: checking for int16_t" >&5
+echo $ECHO_N "checking for int16_t... $ECHO_C" >&6
+if test "${ac_cv_type_int16_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+if ((int16_t *) 0)
+  return 0;
+if (sizeof (int16_t))
+  return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_type_int16_t=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_type_int16_t=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_type_int16_t" >&5
+echo "${ECHO_T}$ac_cv_type_int16_t" >&6
+if test $ac_cv_type_int16_t = yes; then
+  :
+else
+
+cat >>confdefs.h <<_ACEOF
+#define int16_t short
+_ACEOF
+
+fi
+
+echo "$as_me:$LINENO: checking for int32_t" >&5
+echo $ECHO_N "checking for int32_t... $ECHO_C" >&6
+if test "${ac_cv_type_int32_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+if ((int32_t *) 0)
+  return 0;
+if (sizeof (int32_t))
+  return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_type_int32_t=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_type_int32_t=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_type_int32_t" >&5
+echo "${ECHO_T}$ac_cv_type_int32_t" >&6
+if test $ac_cv_type_int32_t = yes; then
+  :
+else
+
+cat >>confdefs.h <<_ACEOF
+#define int32_t long
+_ACEOF
+
+fi
+
+echo "$as_me:$LINENO: checking for int64_t" >&5
+echo $ECHO_N "checking for int64_t... $ECHO_C" >&6
+if test "${ac_cv_type_int64_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+if ((int64_t *) 0)
+  return 0;
+if (sizeof (int64_t))
+  return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_type_int64_t=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_type_int64_t=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_type_int64_t" >&5
+echo "${ECHO_T}$ac_cv_type_int64_t" >&6
+if test $ac_cv_type_int64_t = yes; then
+  :
+else
+
+cat >>confdefs.h <<_ACEOF
+#define int64_t long long
+_ACEOF
+
+fi
+
+
+# Some systems have these in <stdint.h>, just to be difficult...
+echo "$as_me:$LINENO: checking for uint8_t in <stdint.h>" >&5
+echo $ECHO_N "checking for uint8_t in <stdint.h>... $ECHO_C" >&6
+if test "${ucl_cv_uint8_t_in_stdint_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <stdint.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "uint8_t" >/dev/null 2>&1; then
+  ucl_cv_uint8_t_in_stdint_h=yes
+else
+  ucl_cv_uint8_t_in_stdint_h=no
+fi
+rm -f conftest*
+
+fi
+echo "$as_me:$LINENO: result: $ucl_cv_uint8_t_in_stdint_h" >&5
+echo "${ECHO_T}$ucl_cv_uint8_t_in_stdint_h" >&6
+if test $ucl_cv_uint8_t_in_stdint_h = "no"
+then
+	 echo "$as_me:$LINENO: checking for uint8_t" >&5
+echo $ECHO_N "checking for uint8_t... $ECHO_C" >&6
+if test "${ac_cv_type_uint8_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+if ((uint8_t *) 0)
+  return 0;
+if (sizeof (uint8_t))
+  return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_type_uint8_t=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_type_uint8_t=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_type_uint8_t" >&5
+echo "${ECHO_T}$ac_cv_type_uint8_t" >&6
+if test $ac_cv_type_uint8_t = yes; then
+  :
+else
+
+cat >>confdefs.h <<_ACEOF
+#define uint8_t unsigned char
+_ACEOF
+
+fi
+
+fi
+
+echo "$as_me:$LINENO: checking for uint16_t in <stdint.h>" >&5
+echo $ECHO_N "checking for uint16_t in <stdint.h>... $ECHO_C" >&6
+if test "${ucl_cv_uint16_t_in_stdint_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <stdint.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "uint16_t" >/dev/null 2>&1; then
+  ucl_cv_uint16_t_in_stdint_h=yes
+else
+  ucl_cv_uint16_t_in_stdint_h=no
+fi
+rm -f conftest*
+
+fi
+echo "$as_me:$LINENO: result: $ucl_cv_uint16_t_in_stdint_h" >&5
+echo "${ECHO_T}$ucl_cv_uint16_t_in_stdint_h" >&6
+if test $ucl_cv_uint16_t_in_stdint_h = "no"
+then
+	 echo "$as_me:$LINENO: checking for uint16_t" >&5
+echo $ECHO_N "checking for uint16_t... $ECHO_C" >&6
+if test "${ac_cv_type_uint16_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+if ((uint16_t *) 0)
+  return 0;
+if (sizeof (uint16_t))
+  return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_type_uint16_t=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_type_uint16_t=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_type_uint16_t" >&5
+echo "${ECHO_T}$ac_cv_type_uint16_t" >&6
+if test $ac_cv_type_uint16_t = yes; then
+  :
+else
+
+cat >>confdefs.h <<_ACEOF
+#define uint16_t unsigned short
+_ACEOF
+
+fi
+
+fi
+
+echo "$as_me:$LINENO: checking for uint32_t in <stdint.h>" >&5
+echo $ECHO_N "checking for uint32_t in <stdint.h>... $ECHO_C" >&6
+if test "${ucl_cv_uint32_t_in_stdint_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <stdint.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "uint32_t" >/dev/null 2>&1; then
+  ucl_cv_uint32_t_in_stdint_h=yes
+else
+  ucl_cv_uint32_t_in_stdint_h=no
+fi
+rm -f conftest*
+
+fi
+echo "$as_me:$LINENO: result: $ucl_cv_uint32_t_in_stdint_h" >&5
+echo "${ECHO_T}$ucl_cv_uint32_t_in_stdint_h" >&6
+if test $ucl_cv_uint32_t_in_stdint_h = "no"
+then
+	 echo "$as_me:$LINENO: checking for uint32_t" >&5
+echo $ECHO_N "checking for uint32_t... $ECHO_C" >&6
+if test "${ac_cv_type_uint32_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+if ((uint32_t *) 0)
+  return 0;
+if (sizeof (uint32_t))
+  return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_type_uint32_t=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_type_uint32_t=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_type_uint32_t" >&5
+echo "${ECHO_T}$ac_cv_type_uint32_t" >&6
+if test $ac_cv_type_uint32_t = yes; then
+  :
+else
+
+cat >>confdefs.h <<_ACEOF
+#define uint32_t unsigned int
+_ACEOF
+
+fi
+
+fi
+
+###############################################################################
+# The following two macros cause autoconf to complain.
+echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5
+echo $ECHO_N "checking whether byte ordering is bigendian... $ECHO_C" >&6
+if test "${ac_cv_c_bigendian+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  # See if sys/param.h defines the BYTE_ORDER macro.
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <sys/types.h>
+#include <sys/param.h>
+
+int
+main ()
+{
+#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
+ bogus endian macros
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  # It does; now see whether it defined to BIG_ENDIAN or not.
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <sys/types.h>
+#include <sys/param.h>
+
+int
+main ()
+{
+#if BYTE_ORDER != BIG_ENDIAN
+ not big endian
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_c_bigendian=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_c_bigendian=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+# It does not; compile a test program.
+if test "$cross_compiling" = yes; then
+  # try to guess the endianness by grepping values into an object file
+  ac_cv_c_bigendian=unknown
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+short ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 };
+short ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 };
+void _ascii () { char *s = (char *) ascii_mm; s = (char *) ascii_ii; }
+short ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 };
+short ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 };
+void _ebcdic () { char *s = (char *) ebcdic_mm; s = (char *) ebcdic_ii; }
+int
+main ()
+{
+ _ascii (); _ebcdic ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then
+  ac_cv_c_bigendian=yes
+fi
+if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then
+  if test "$ac_cv_c_bigendian" = unknown; then
+    ac_cv_c_bigendian=no
+  else
+    # finding both strings is unlikely to happen, but who knows?
+    ac_cv_c_bigendian=unknown
+  fi
+fi
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+int
+main ()
+{
+  /* Are we little or big endian?  From Harbison&Steele.  */
+  union
+  {
+    long l;
+    char c[sizeof (long)];
+  } u;
+  u.l = 1;
+  exit (u.c[sizeof (long) - 1] == 1);
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_c_bigendian=no
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_c_bigendian=yes
+fi
+rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5
+echo "${ECHO_T}$ac_cv_c_bigendian" >&6
+case $ac_cv_c_bigendian in
+  yes)
+
+cat >>confdefs.h <<\_ACEOF
+#define WORDS_BIGENDIAN 1
+_ACEOF
+ ;;
+  no)
+     ;;
+  *)
+    { { echo "$as_me:$LINENO: error: unknown endianness
+presetting ac_cv_c_bigendian=no (or yes) will help" >&5
+echo "$as_me: error: unknown endianness
+presetting ac_cv_c_bigendian=no (or yes) will help" >&2;}
+   { (exit 1); exit 1; }; } ;;
+esac
+
+
+echo "$as_me:$LINENO: checking whether char is unsigned" >&5
+echo $ECHO_N "checking whether char is unsigned... $ECHO_C" >&6
+if test "${ac_cv_c_char_unsigned+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((char) -1) < 0)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_c_char_unsigned=no
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_c_char_unsigned=yes
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_c_char_unsigned" >&5
+echo "${ECHO_T}$ac_cv_c_char_unsigned" >&6
+if test $ac_cv_c_char_unsigned = yes && test "$GCC" != yes; then
+  cat >>confdefs.h <<\_ACEOF
+#define __CHAR_UNSIGNED__ 1
+_ACEOF
+
+fi
+
+#
+# Some of the codecs in rat don't with with unsigned characters.
+# Force the compiler to use signed chars, to be consistent.
+if test $ac_cv_c_char_unsigned = yes
+then
+	if test "$GCC" = yes
+	then
+		CFLAGS="$CFLAGS -fsigned-char"
+	else
+		case "$host_os" in
+		# I don't know when "-signed" was added to IRIX CC
+		# so err on the side of using it.
+		irix*)	CFLAGS="$CFLAGS -signed"
+			;;
+		# need e.g. --force-signed-chars=-signed
+		*)	{ { echo "$as_me:$LINENO: error: I don't know how to force signed chars" >&5
+echo "$as_me: error: I don't know how to force signed chars" >&2;}
+   { (exit 1); exit 1; }; }
+			;;
+		esac
+	fi
+fi
+#  __CHAR_UNSIGNED__ will be defined; hope this is OK.
+
+###############################################################################
+# The following causes autoconf to complain.
+echo "$as_me:$LINENO: checking for /dev/urandom" >&5
+echo $ECHO_N "checking for /dev/urandom... $ECHO_C" >&6
+if test "${ac_cv_file__dev_urandom+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  test "$cross_compiling" = yes &&
+  { { echo "$as_me:$LINENO: error: cannot check for file existence when cross compiling" >&5
+echo "$as_me: error: cannot check for file existence when cross compiling" >&2;}
+   { (exit 1); exit 1; }; }
+if test -r "/dev/urandom"; then
+  ac_cv_file__dev_urandom=yes
+else
+  ac_cv_file__dev_urandom=no
+fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_file__dev_urandom" >&5
+echo "${ECHO_T}$ac_cv_file__dev_urandom" >&6
+if test $ac_cv_file__dev_urandom = yes; then
+  cat >>confdefs.h <<\_ACEOF
+#define HAVE_DEV_URANDOM 1
+_ACEOF
+
+fi
+
+
+# If more files than mbus.c use vsnprintf, split it out into
+# vsnprintf.c and add it to AC_REPLACE_FUNCS
+# AC_CHECK_FUNC(vsnprintf,,AC_DEFINE(NEED_VSNPRINTF))
+
+for ac_func in vsnprintf
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+char (*f) () = $ac_func;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != $ac_func;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "$as_ac_var=no"
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+else
+  LIBOBJS="$LIBOBJS $ac_func.$ac_objext"
+fi
+done
+
+
+
+###############################################################################
+# If inet_aton is actually needed somewhere, split it out into
+# inet_aton.c and add it to AC_REPLACE_FUNCS
+#
+# AC_CHECK_FUNC succeeds on our IRIX 6.2 boxes, but it is not
+# declared anywhere, use egrep header to check (ugh lame, but works)
+
+
+
+
+for ac_func in inet_pton inet_ntop inet_aton
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+char (*f) () = $ac_func;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != $ac_func;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "$as_ac_var=no"
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+echo "$as_me:$LINENO: checking for library containing socket" >&5
+echo $ECHO_N "checking for library containing socket... $ECHO_C" >&6
+if test "${ac_cv_search_socket+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_func_search_save_LIBS=$LIBS
+ac_cv_search_socket=no
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char socket ();
+int
+main ()
+{
+socket ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_search_socket="none required"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+if test "$ac_cv_search_socket" = no; then
+  for ac_lib in socket; do
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+    cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char socket ();
+int
+main ()
+{
+socket ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_search_socket="-l$ac_lib"
+break
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+  done
+fi
+LIBS=$ac_func_search_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_search_socket" >&5
+echo "${ECHO_T}$ac_cv_search_socket" >&6
+if test "$ac_cv_search_socket" != no; then
+  test "$ac_cv_search_socket" = "none required" || LIBS="$ac_cv_search_socket $LIBS"
+
+fi
+
+echo "$as_me:$LINENO: checking for library containing inet_addr" >&5
+echo $ECHO_N "checking for library containing inet_addr... $ECHO_C" >&6
+if test "${ac_cv_search_inet_addr+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_func_search_save_LIBS=$LIBS
+ac_cv_search_inet_addr=no
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char inet_addr ();
+int
+main ()
+{
+inet_addr ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_search_inet_addr="none required"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+if test "$ac_cv_search_inet_addr" = no; then
+  for ac_lib in nsl; do
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+    cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char inet_addr ();
+int
+main ()
+{
+inet_addr ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_search_inet_addr="-l$ac_lib"
+break
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+  done
+fi
+LIBS=$ac_func_search_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_search_inet_addr" >&5
+echo "${ECHO_T}$ac_cv_search_inet_addr" >&6
+if test "$ac_cv_search_inet_addr" != no; then
+  test "$ac_cv_search_inet_addr" = "none required" || LIBS="$ac_cv_search_inet_addr $LIBS"
+
+fi
+
+
+###############################################################################
+#  -profile
+# Check whether --enable-profile or --disable-profile was given.
+if test "${enable_profile+set}" = set; then
+  enableval="$enable_profile"
+  if test $enableval = yes
+	then
+		if test "$GCC" = yes
+		then
+			CFLAGS="$CFLAGS -pg"
+		else
+			{ { echo "$as_me:$LINENO: error: Don't know how to enable profiling for $CC" >&5
+echo "$as_me: error: Don't know how to enable profiling for $CC" >&2;}
+   { (exit 1); exit 1; }; }
+		fi
+	fi
+fi;
+
+#  -bounds
+#       add -fbounds-checking to CFLAGS
+#       add -lcheck to LIBS
+# Check whether --enable-bounds or --disable-bounds was given.
+if test "${enable_bounds+set}" = set; then
+  enableval="$enable_bounds"
+  if test $enableval = yes
+	then
+		if test "$GCC" = yes
+		then
+			CFLAGS="$CFLAGS -fbounds-checking"
+			LIBS="$LIBS -lcheck"
+		else
+			{ { echo "$as_me:$LINENO: error: Don't know how to enable profiling for $CC" >&5
+echo "$as_me: error: Don't know how to enable profiling for $CC" >&2;}
+   { (exit 1); exit 1; }; }
+		fi
+	fi
+fi;
+
+# -DDEBUG
+# -DDEBUG_MEM
+# -DNDEBUG
+# Check whether --enable-debug or --disable-debug was given.
+if test "${enable_debug+set}" = set; then
+  enableval="$enable_debug"
+  if test $enableval = yes
+	then
+		cat >>confdefs.h <<\_ACEOF
+#define DEBUG 1
+_ACEOF
+
+	fi
+fi;
+# Check whether --enable-debug-mem or --disable-debug-mem was given.
+if test "${enable_debug_mem+set}" = set; then
+  enableval="$enable_debug_mem"
+  if test $enableval = yes
+	then
+		cat >>confdefs.h <<\_ACEOF
+#define DEBUG_MEM 1
+_ACEOF
+
+	fi
+fi;
+
+###############################################################################
+# IPv6 related configuration options
+
+# Check whether --enable-ipv6 or --disable-ipv6 was given.
+if test "${enable_ipv6+set}" = set; then
+  enableval="$enable_ipv6"
+  cat >>confdefs.h <<\_ACEOF
+#define HAVE_IPv6 1
+_ACEOF
+
+fi;
+
+# Check whether --enable-kame-ipv6 or --disable-kame-ipv6 was given.
+if test "${enable_kame_ipv6+set}" = set; then
+  enableval="$enable_kame_ipv6"
+
+		cat >>confdefs.h <<\_ACEOF
+#define HAVE_IPv6 1
+_ACEOF
+
+		LIBS="$LIBS -L/usr/local/v6/lib -linet6"
+
+fi;
+
+# Test below are IPv6 specific.  Their result has no bearing if HAVE_IPv6 is
+# not defined.  They are kept outside IPv6 enable check to keep code readable.
+
+echo "$as_me:$LINENO: checking for getipnodebyname in <netdb.h>" >&5
+echo $ECHO_N "checking for getipnodebyname in <netdb.h>... $ECHO_C" >&6
+if test "${ucl_cv_getipnodebyname_in_netdb_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <netdb.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "getipnodebyname" >/dev/null 2>&1; then
+  ucl_cv_getipnodebyname_in_netdb_h=yes
+else
+  ucl_cv_getipnodebyname_in_netdb_h=no
+fi
+rm -f conftest*
+
+fi
+echo "$as_me:$LINENO: result: $ucl_cv_getipnodebyname_in_netdb_h" >&5
+echo "${ECHO_T}$ucl_cv_getipnodebyname_in_netdb_h" >&6
+if test $ucl_cv_getipnodebyname_in_netdb_h
+then
+	cat >>confdefs.h <<\_ACEOF
+#define HAVE_GETIPNODEBYNAME 1
+_ACEOF
+
+fi
+
+
+for ac_header in netinet6/in6.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+else
+  # Is the header compilable?
+echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_header_compiler=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc in
+  yes:no )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    (
+      cat <<\_ASBOX
+## ------------------------------------ ##
+## Report this to bug-autoconf at gnu.org. ##
+## ------------------------------------ ##
+_ASBOX
+    ) |
+      sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+  no:yes )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    (
+      cat <<\_ASBOX
+## ------------------------------------ ##
+## Report this to bug-autoconf at gnu.org. ##
+## ------------------------------------ ##
+_ASBOX
+    ) |
+      sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=$ac_header_preproc"
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in netinet/ip6.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+else
+  # Is the header compilable?
+echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_header_compiler=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc in
+  yes:no )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    (
+      cat <<\_ASBOX
+## ------------------------------------ ##
+## Report this to bug-autoconf at gnu.org. ##
+## ------------------------------------ ##
+_ASBOX
+    ) |
+      sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+  no:yes )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    (
+      cat <<\_ASBOX
+## ------------------------------------ ##
+## Report this to bug-autoconf at gnu.org. ##
+## ------------------------------------ ##
+_ASBOX
+    ) |
+      sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=$ac_header_preproc"
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+echo "$as_me:$LINENO: checking for struct addrinfo in <netdb.h>" >&5
+echo $ECHO_N "checking for struct addrinfo in <netdb.h>... $ECHO_C" >&6
+if test "${ucl_cv_st_addrinfo_in_netdb_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <netdb.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "addrinfo" >/dev/null 2>&1; then
+  ucl_cv_st_addrinfo_in_netdb_h=yes
+else
+  ucl_cv_st_addrinfo_in_netdb_h=no
+fi
+rm -f conftest*
+
+fi
+echo "$as_me:$LINENO: result: $ucl_cv_st_addrinfo_in_netdb_h" >&5
+echo "${ECHO_T}$ucl_cv_st_addrinfo_in_netdb_h" >&6
+if test $ucl_cv_st_addrinfo_in_netdb_h
+then
+	cat >>confdefs.h <<\_ACEOF
+#define HAVE_ST_ADDRINFO 1
+_ACEOF
+
+fi
+
+echo "$as_me:$LINENO: checking for sin6_len in struct sockaddr_in6" >&5
+echo $ECHO_N "checking for sin6_len in struct sockaddr_in6... $ECHO_C" >&6
+if test "${ucl_cv_sin6_len+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+		#ifdef HAVE_NETINET6_IN6_H
+		#include <netinet6/in6.h>
+		#else
+		#ifdef HAVE_NETINET_IP6_H
+		#include <netinet/ip6.h>
+		#else
+		#include <netinet/in.h>
+		#endif
+		#endif /* HAVE_NETINET_IN6_H */
+
+int
+main ()
+{
+
+		struct sockaddr_in6	s_in;
+		s_in.sin6_len = 0;
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ucl_cv_sin6_len=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ucl_cv_sin6_len=no
+
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ucl_cv_sin6_len" >&5
+echo "${ECHO_T}$ucl_cv_sin6_len" >&6
+if test $ucl_cv_sin6_len = yes
+then
+	cat >>confdefs.h <<\_ACEOF
+#define HAVE_SIN6_LEN 1
+_ACEOF
+
+fi
+
+###############################################################################
+# Check whether gtk-doc is installed
+
+# Extract the first word of "gtkdoc-scan", so it can be a program name with args.
+set dummy gtkdoc-scan; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_GTKDOC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$GTKDOC"; then
+  ac_cv_prog_GTKDOC="$GTKDOC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_GTKDOC="yes"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+  test -z "$ac_cv_prog_GTKDOC" && ac_cv_prog_GTKDOC="no"
+fi
+fi
+GTKDOC=$ac_cv_prog_GTKDOC
+if test -n "$GTKDOC"; then
+  echo "$as_me:$LINENO: result: $GTKDOC" >&5
+echo "${ECHO_T}$GTKDOC" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+if test "$GTKDOC" = yes
+then
+	OPTDOC=doc
+else
+	OPTDOC=
+fi
+
+
+###############################################################################
+# GCC-specific warning flags
+if test "$GCC" = yes
+then
+        CFLAGS="$CFLAGS -W -Wall -Wwrite-strings -Wbad-function-cast -Wmissing-prototypes -Wmissing-declarations -Werror"
+fi
+
+###############################################################################
+# Done, create the output files....
+                    ac_config_files="$ac_config_files Makefile win32/Makefile"
+cat >confcache <<\_ACEOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs, see configure's option --config-cache.
+# It is not useful on other systems.  If it contains results you don't
+# want to keep, you may remove or edit it.
+#
+# config.status only pays attention to the cache file if you give it
+# the --recheck option to rerun configure.
+#
+# `ac_cv_env_foo' variables (set or unset) will be overridden when
+# loading this file, other *unset* `ac_cv_foo' will be assigned the
+# following values.
+
+_ACEOF
+
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, don't put newlines in cache variables' values.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+{
+  (set) 2>&1 |
+    case `(ac_space=' '; set | grep ac_space) 2>&1` in
+    *ac_space=\ *)
+      # `set' does not quote correctly, so add quotes (double-quote
+      # substitution turns \\\\ into \\, and sed turns \\ into \).
+      sed -n \
+        "s/'/'\\\\''/g;
+    	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
+      ;;
+    *)
+      # `set' quotes correctly as required by POSIX, so do not add quotes.
+      sed -n \
+        "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
+      ;;
+    esac;
+} |
+  sed '
+     t clear
+     : clear
+     s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
+     t end
+     /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
+     : end' >>confcache
+if diff $cache_file confcache >/dev/null 2>&1; then :; else
+  if test -w $cache_file; then
+    test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file"
+    cat confcache >$cache_file
+  else
+    echo "not updating unwritable cache $cache_file"
+  fi
+fi
+rm -f confcache
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+# VPATH may cause trouble with some makes, so we remove $(srcdir),
+# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
+# trailing colons and then remove the whole line if VPATH becomes empty
+# (actually we leave an empty line to preserve line numbers).
+if test "x$srcdir" = x.; then
+  ac_vpsub='/^[ 	]*VPATH[ 	]*=/{
+s/:*\$(srcdir):*/:/;
+s/:*\${srcdir}:*/:/;
+s/:*@srcdir@:*/:/;
+s/^\([^=]*=[ 	]*\):*/\1/;
+s/:*$//;
+s/^[^=]*=[ 	]*$//;
+}'
+fi
+
+DEFS=-DHAVE_CONFIG_H
+
+ac_libobjs=
+ac_ltlibobjs=
+for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
+  # 1. Remove the extension, and $U if already installed.
+  ac_i=`echo "$ac_i" |
+         sed 's/\$U\././;s/\.o$//;s/\.obj$//'`
+  # 2. Add them.
+  ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext"
+  ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo'
+done
+LIBOBJS=$ac_libobjs
+
+LTLIBOBJS=$ac_ltlibobjs
+
+
+if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then
+  { { echo "$as_me:$LINENO: error: conditional \"AMDEP\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"AMDEP\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
+  { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"am__fastdepCC\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+: ${CONFIG_STATUS=./config.status}
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files $CONFIG_STATUS"
+{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5
+echo "$as_me: creating $CONFIG_STATUS" >&6;}
+cat >$CONFIG_STATUS <<_ACEOF
+#! $SHELL
+# Generated by $as_me.
+# Run this file to recreate the current configuration.
+# Compiler output produced by configure, useful for debugging
+# configure, is in config.log if it exists.
+
+debug=false
+ac_cs_recheck=false
+ac_cs_silent=false
+SHELL=\${CONFIG_SHELL-$SHELL}
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+## --------------------- ##
+## M4sh Initialization.  ##
+## --------------------- ##
+
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
+  set -o posix
+fi
+
+# Support unset when possible.
+if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
+  as_unset=unset
+else
+  as_unset=false
+fi
+
+
+# Work around bugs in pre-3.0 UWIN ksh.
+$as_unset ENV MAIL MAILPATH
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+for as_var in \
+  LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
+  LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
+  LC_TELEPHONE LC_TIME
+do
+  if (set +x; test -n "`(eval $as_var=C; export $as_var) 2>&1`"); then
+    eval $as_var=C; export $as_var
+  else
+    $as_unset $as_var
+  fi
+done
+
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
+  as_basename=basename
+else
+  as_basename=false
+fi
+
+
+# Name of the executable.
+as_me=`$as_basename "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+	 X"$0" : 'X\(//\)$' \| \
+	 X"$0" : 'X\(/\)$' \| \
+	 .     : '\(.\)' 2>/dev/null ||
+echo X/"$0" |
+    sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
+  	  /^X\/\(\/\/\)$/{ s//\1/; q; }
+  	  /^X\/\(\/\).*/{ s//\1/; q; }
+  	  s/.*/./; q'`
+
+
+# PATH needs CR, and LINENO needs CR and PATH.
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  echo "#! /bin/sh" >conf$$.sh
+  echo  "exit 0"   >>conf$$.sh
+  chmod +x conf$$.sh
+  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+    PATH_SEPARATOR=';'
+  else
+    PATH_SEPARATOR=:
+  fi
+  rm -f conf$$.sh
+fi
+
+
+  as_lineno_1=$LINENO
+  as_lineno_2=$LINENO
+  as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+  test "x$as_lineno_1" != "x$as_lineno_2" &&
+  test "x$as_lineno_3"  = "x$as_lineno_2"  || {
+  # Find who we are.  Look in the path if we contain no path at all
+  # relative or not.
+  case $0 in
+    *[\\/]* ) as_myself=$0 ;;
+    *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+done
+
+       ;;
+  esac
+  # We did not find ourselves, most probably we were run as `sh COMMAND'
+  # in which case we are not to be found in the path.
+  if test "x$as_myself" = x; then
+    as_myself=$0
+  fi
+  if test ! -f "$as_myself"; then
+    { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5
+echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;}
+   { (exit 1); exit 1; }; }
+  fi
+  case $CONFIG_SHELL in
+  '')
+    as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for as_base in sh bash ksh sh5; do
+	 case $as_dir in
+	 /*)
+	   if ("$as_dir/$as_base" -c '
+  as_lineno_1=$LINENO
+  as_lineno_2=$LINENO
+  as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+  test "x$as_lineno_1" != "x$as_lineno_2" &&
+  test "x$as_lineno_3"  = "x$as_lineno_2" ') 2>/dev/null; then
+	     $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
+	     $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
+	     CONFIG_SHELL=$as_dir/$as_base
+	     export CONFIG_SHELL
+	     exec "$CONFIG_SHELL" "$0" ${1+"$@"}
+	   fi;;
+	 esac
+       done
+done
+;;
+  esac
+
+  # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
+  # uniformly replaced by the line number.  The first 'sed' inserts a
+  # line-number line before each line; the second 'sed' does the real
+  # work.  The second script uses 'N' to pair each line-number line
+  # with the numbered line, and appends trailing '-' during
+  # substitution so that $LINENO is not a special case at line end.
+  # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
+  # second 'sed' script.  Blame Lee E. McMahon for sed's syntax.  :-)
+  sed '=' <$as_myself |
+    sed '
+      N
+      s,$,-,
+      : loop
+      s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
+      t loop
+      s,-$,,
+      s,^['$as_cr_digits']*\n,,
+    ' >$as_me.lineno &&
+  chmod +x $as_me.lineno ||
+    { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5
+echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;}
+   { (exit 1); exit 1; }; }
+
+  # Don't try to exec as it changes $[0], causing all sort of problems
+  # (the dirname of $[0] is not the place where we might find the
+  # original and so on.  Autoconf is especially sensible to this).
+  . ./$as_me.lineno
+  # Exit status is that of the last command.
+  exit
+}
+
+
+case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
+  *c*,-n*) ECHO_N= ECHO_C='
+' ECHO_T='	' ;;
+  *c*,*  ) ECHO_N=-n ECHO_C= ECHO_T= ;;
+  *)       ECHO_N= ECHO_C='\c' ECHO_T= ;;
+esac
+
+if expr a : '\(a\)' >/dev/null 2>&1; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+rm -f conf$$ conf$$.exe conf$$.file
+echo >conf$$.file
+if ln -s conf$$.file conf$$ 2>/dev/null; then
+  # We could just check for DJGPP; but this test a) works b) is more generic
+  # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
+  if test -f conf$$.exe; then
+    # Don't use ln at all; we don't have any links
+    as_ln_s='cp -p'
+  else
+    as_ln_s='ln -s'
+  fi
+elif ln conf$$.file conf$$ 2>/dev/null; then
+  as_ln_s=ln
+else
+  as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.file
+
+if mkdir -p . 2>/dev/null; then
+  as_mkdir_p=:
+else
+  as_mkdir_p=false
+fi
+
+as_executable_p="test -f"
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g"
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.
+as_nl='
+'
+IFS=" 	$as_nl"
+
+# CDPATH.
+$as_unset CDPATH
+
+exec 6>&1
+
+# Open the log real soon, to keep \$[0] and so on meaningful, and to
+# report actual input values of CONFIG_FILES etc. instead of their
+# values after options handling.  Logging --version etc. is OK.
+exec 5>>config.log
+{
+  echo
+  sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
+## Running $as_me. ##
+_ASBOX
+} >&5
+cat >&5 <<_CSEOF
+
+This file was extended by $as_me, which was
+generated by GNU Autoconf 2.57.  Invocation command line was
+
+  CONFIG_FILES    = $CONFIG_FILES
+  CONFIG_HEADERS  = $CONFIG_HEADERS
+  CONFIG_LINKS    = $CONFIG_LINKS
+  CONFIG_COMMANDS = $CONFIG_COMMANDS
+  $ $0 $@
+
+_CSEOF
+echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5
+echo >&5
+_ACEOF
+
+# Files that config.status was made for.
+if test -n "$ac_config_files"; then
+  echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS
+fi
+
+if test -n "$ac_config_headers"; then
+  echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS
+fi
+
+if test -n "$ac_config_links"; then
+  echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS
+fi
+
+if test -n "$ac_config_commands"; then
+  echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS
+fi
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+
+ac_cs_usage="\
+\`$as_me' instantiates files from templates according to the
+current configuration.
+
+Usage: $0 [OPTIONS] [FILE]...
+
+  -h, --help       print this help, then exit
+  -V, --version    print version number, then exit
+  -q, --quiet      do not print progress messages
+  -d, --debug      don't remove temporary files
+      --recheck    update $as_me by reconfiguring in the same conditions
+  --file=FILE[:TEMPLATE]
+                   instantiate the configuration file FILE
+  --header=FILE[:TEMPLATE]
+                   instantiate the configuration header FILE
+
+Configuration files:
+$config_files
+
+Configuration headers:
+$config_headers
+
+Configuration commands:
+$config_commands
+
+Report bugs to <bug-autoconf at gnu.org>."
+_ACEOF
+
+cat >>$CONFIG_STATUS <<_ACEOF
+ac_cs_version="\\
+config.status
+configured by $0, generated by GNU Autoconf 2.57,
+  with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
+
+Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
+Free Software Foundation, Inc.
+This config.status script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it."
+srcdir=$srcdir
+INSTALL="$INSTALL"
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+# If no file are specified by the user, then we need to provide default
+# value.  By we need to know if files were specified by the user.
+ac_need_defaults=:
+while test $# != 0
+do
+  case $1 in
+  --*=*)
+    ac_option=`expr "x$1" : 'x\([^=]*\)='`
+    ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
+    ac_shift=:
+    ;;
+  -*)
+    ac_option=$1
+    ac_optarg=$2
+    ac_shift=shift
+    ;;
+  *) # This is not an option, so the user has probably given explicit
+     # arguments.
+     ac_option=$1
+     ac_need_defaults=false;;
+  esac
+
+  case $ac_option in
+  # Handling of the options.
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+  -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+    ac_cs_recheck=: ;;
+  --version | --vers* | -V )
+    echo "$ac_cs_version"; exit 0 ;;
+  --he | --h)
+    # Conflict between --help and --header
+    { { echo "$as_me:$LINENO: error: ambiguous option: $1
+Try \`$0 --help' for more information." >&5
+echo "$as_me: error: ambiguous option: $1
+Try \`$0 --help' for more information." >&2;}
+   { (exit 1); exit 1; }; };;
+  --help | --hel | -h )
+    echo "$ac_cs_usage"; exit 0 ;;
+  --debug | --d* | -d )
+    debug=: ;;
+  --file | --fil | --fi | --f )
+    $ac_shift
+    CONFIG_FILES="$CONFIG_FILES $ac_optarg"
+    ac_need_defaults=false;;
+  --header | --heade | --head | --hea )
+    $ac_shift
+    CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg"
+    ac_need_defaults=false;;
+  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+  | -silent | --silent | --silen | --sile | --sil | --si | --s)
+    ac_cs_silent=: ;;
+
+  # This is an error.
+  -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1
+Try \`$0 --help' for more information." >&5
+echo "$as_me: error: unrecognized option: $1
+Try \`$0 --help' for more information." >&2;}
+   { (exit 1); exit 1; }; } ;;
+
+  *) ac_config_targets="$ac_config_targets $1" ;;
+
+  esac
+  shift
+done
+
+ac_configure_extra_args=
+
+if $ac_cs_silent; then
+  exec 6>/dev/null
+  ac_configure_extra_args="$ac_configure_extra_args --silent"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF
+if \$ac_cs_recheck; then
+  echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6
+  exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+fi
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<_ACEOF
+#
+# INIT-COMMANDS section.
+#
+
+AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"
+
+_ACEOF
+
+
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+for ac_config_target in $ac_config_targets
+do
+  case "$ac_config_target" in
+  # Handling of arguments.
+  "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+  "win32/Makefile" ) CONFIG_FILES="$CONFIG_FILES win32/Makefile" ;;
+  "depfiles" ) CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
+  "uclconf.h" ) CONFIG_HEADERS="$CONFIG_HEADERS uclconf.h:config.h.in" ;;
+  *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
+echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
+   { (exit 1); exit 1; }; };;
+  esac
+done
+
+# If the user did not use the arguments to specify the items to instantiate,
+# then the envvar interface is used.  Set only those that are not.
+# We use the long form for the default assignment because of an extremely
+# bizarre bug on SunOS 4.1.3.
+if $ac_need_defaults; then
+  test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
+  test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
+  test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
+fi
+
+# Have a temporary directory for convenience.  Make it in the build tree
+# simply because there is no reason to put it here, and in addition,
+# creating and moving files from /tmp can sometimes cause problems.
+# Create a temporary directory, and hook for its removal unless debugging.
+$debug ||
+{
+  trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0
+  trap '{ (exit 1); exit 1; }' 1 2 13 15
+}
+
+# Create a (secure) tmp directory for tmp files.
+
+{
+  tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` &&
+  test -n "$tmp" && test -d "$tmp"
+}  ||
+{
+  tmp=./confstat$$-$RANDOM
+  (umask 077 && mkdir $tmp)
+} ||
+{
+   echo "$me: cannot create a temporary directory in ." >&2
+   { (exit 1); exit 1; }
+}
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<_ACEOF
+
+#
+# CONFIG_FILES section.
+#
+
+# No need to generate the scripts if there are no CONFIG_FILES.
+# This happens for instance when ./config.status config.h
+if test -n "\$CONFIG_FILES"; then
+  # Protect against being on the right side of a sed subst in config.status.
+  sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g;
+   s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF
+s, at SHELL@,$SHELL,;t t
+s, at PATH_SEPARATOR@,$PATH_SEPARATOR,;t t
+s, at PACKAGE_NAME@,$PACKAGE_NAME,;t t
+s, at PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t
+s, at PACKAGE_VERSION@,$PACKAGE_VERSION,;t t
+s, at PACKAGE_STRING@,$PACKAGE_STRING,;t t
+s, at PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t
+s, at exec_prefix@,$exec_prefix,;t t
+s, at prefix@,$prefix,;t t
+s, at program_transform_name@,$program_transform_name,;t t
+s, at bindir@,$bindir,;t t
+s, at sbindir@,$sbindir,;t t
+s, at libexecdir@,$libexecdir,;t t
+s, at datadir@,$datadir,;t t
+s, at sysconfdir@,$sysconfdir,;t t
+s, at sharedstatedir@,$sharedstatedir,;t t
+s, at localstatedir@,$localstatedir,;t t
+s, at libdir@,$libdir,;t t
+s, at includedir@,$includedir,;t t
+s, at oldincludedir@,$oldincludedir,;t t
+s, at infodir@,$infodir,;t t
+s, at mandir@,$mandir,;t t
+s, at build_alias@,$build_alias,;t t
+s, at host_alias@,$host_alias,;t t
+s, at target_alias@,$target_alias,;t t
+s, at DEFS@,$DEFS,;t t
+s, at ECHO_C@,$ECHO_C,;t t
+s, at ECHO_N@,$ECHO_N,;t t
+s, at ECHO_T@,$ECHO_T,;t t
+s, at LIBS@,$LIBS,;t t
+s, at INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t
+s, at INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t
+s, at INSTALL_DATA@,$INSTALL_DATA,;t t
+s, at CYGPATH_W@,$CYGPATH_W,;t t
+s, at PACKAGE@,$PACKAGE,;t t
+s, at VERSION@,$VERSION,;t t
+s, at ACLOCAL@,$ACLOCAL,;t t
+s, at AUTOCONF@,$AUTOCONF,;t t
+s, at AUTOMAKE@,$AUTOMAKE,;t t
+s, at AUTOHEADER@,$AUTOHEADER,;t t
+s, at MAKEINFO@,$MAKEINFO,;t t
+s, at AMTAR@,$AMTAR,;t t
+s, at install_sh@,$install_sh,;t t
+s, at STRIP@,$STRIP,;t t
+s, at ac_ct_STRIP@,$ac_ct_STRIP,;t t
+s, at INSTALL_STRIP_PROGRAM@,$INSTALL_STRIP_PROGRAM,;t t
+s, at AWK@,$AWK,;t t
+s, at SET_MAKE@,$SET_MAKE,;t t
+s, at build@,$build,;t t
+s, at build_cpu@,$build_cpu,;t t
+s, at build_vendor@,$build_vendor,;t t
+s, at build_os@,$build_os,;t t
+s, at host@,$host,;t t
+s, at host_cpu@,$host_cpu,;t t
+s, at host_vendor@,$host_vendor,;t t
+s, at host_os@,$host_os,;t t
+s, at target@,$target,;t t
+s, at target_cpu@,$target_cpu,;t t
+s, at target_vendor@,$target_vendor,;t t
+s, at target_os@,$target_os,;t t
+s, at CC@,$CC,;t t
+s, at CFLAGS@,$CFLAGS,;t t
+s, at LDFLAGS@,$LDFLAGS,;t t
+s, at CPPFLAGS@,$CPPFLAGS,;t t
+s, at ac_ct_CC@,$ac_ct_CC,;t t
+s, at EXEEXT@,$EXEEXT,;t t
+s, at OBJEXT@,$OBJEXT,;t t
+s, at DEPDIR@,$DEPDIR,;t t
+s, at am__include@,$am__include,;t t
+s, at am__quote@,$am__quote,;t t
+s, at AMDEP_TRUE@,$AMDEP_TRUE,;t t
+s, at AMDEP_FALSE@,$AMDEP_FALSE,;t t
+s, at AMDEPBACKSLASH@,$AMDEPBACKSLASH,;t t
+s, at CCDEPMODE@,$CCDEPMODE,;t t
+s, at am__fastdepCC_TRUE@,$am__fastdepCC_TRUE,;t t
+s, at am__fastdepCC_FALSE@,$am__fastdepCC_FALSE,;t t
+s, at CPP@,$CPP,;t t
+s, at LN_S@,$LN_S,;t t
+s, at ECHO@,$ECHO,;t t
+s, at RANLIB@,$RANLIB,;t t
+s, at ac_ct_RANLIB@,$ac_ct_RANLIB,;t t
+s, at EGREP@,$EGREP,;t t
+s, at LIBTOOL@,$LIBTOOL,;t t
+s, at LIBOBJS@,$LIBOBJS,;t t
+s, at GTKDOC@,$GTKDOC,;t t
+s, at OPTDOC@,$OPTDOC,;t t
+s, at LTLIBOBJS@,$LTLIBOBJS,;t t
+CEOF
+
+_ACEOF
+
+  cat >>$CONFIG_STATUS <<\_ACEOF
+  # Split the substitutions into bite-sized pieces for seds with
+  # small command number limits, like on Digital OSF/1 and HP-UX.
+  ac_max_sed_lines=48
+  ac_sed_frag=1 # Number of current file.
+  ac_beg=1 # First line for current file.
+  ac_end=$ac_max_sed_lines # Line after last line for current file.
+  ac_more_lines=:
+  ac_sed_cmds=
+  while $ac_more_lines; do
+    if test $ac_beg -gt 1; then
+      sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
+    else
+      sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
+    fi
+    if test ! -s $tmp/subs.frag; then
+      ac_more_lines=false
+    else
+      # The purpose of the label and of the branching condition is to
+      # speed up the sed processing (if there are no `@' at all, there
+      # is no need to browse any of the substitutions).
+      # These are the two extra sed commands mentioned above.
+      (echo ':t
+  /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed
+      if test -z "$ac_sed_cmds"; then
+  	ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed"
+      else
+  	ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed"
+      fi
+      ac_sed_frag=`expr $ac_sed_frag + 1`
+      ac_beg=$ac_end
+      ac_end=`expr $ac_end + $ac_max_sed_lines`
+    fi
+  done
+  if test -z "$ac_sed_cmds"; then
+    ac_sed_cmds=cat
+  fi
+fi # test -n "$CONFIG_FILES"
+
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue
+  # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+  case $ac_file in
+  - | *:- | *:-:* ) # input from stdin
+        cat >$tmp/stdin
+        ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+        ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+  *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+        ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+  * )   ac_file_in=$ac_file.in ;;
+  esac
+
+  # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories.
+  ac_dir=`(dirname "$ac_file") 2>/dev/null ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+         X"$ac_file" : 'X\(//\)[^/]' \| \
+         X"$ac_file" : 'X\(//\)$' \| \
+         X"$ac_file" : 'X\(/\)' \| \
+         .     : '\(.\)' 2>/dev/null ||
+echo X"$ac_file" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+  	  /^X\(\/\/\)$/{ s//\1/; q; }
+  	  /^X\(\/\).*/{ s//\1/; q; }
+  	  s/.*/./; q'`
+  { if $as_mkdir_p; then
+    mkdir -p "$ac_dir"
+  else
+    as_dir="$ac_dir"
+    as_dirs=
+    while test ! -d "$as_dir"; do
+      as_dirs="$as_dir $as_dirs"
+      as_dir=`(dirname "$as_dir") 2>/dev/null ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+         X"$as_dir" : 'X\(//\)[^/]' \| \
+         X"$as_dir" : 'X\(//\)$' \| \
+         X"$as_dir" : 'X\(/\)' \| \
+         .     : '\(.\)' 2>/dev/null ||
+echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+  	  /^X\(\/\/\)$/{ s//\1/; q; }
+  	  /^X\(\/\).*/{ s//\1/; q; }
+  	  s/.*/./; q'`
+    done
+    test ! -n "$as_dirs" || mkdir $as_dirs
+  fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
+echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
+   { (exit 1); exit 1; }; }; }
+
+  ac_builddir=.
+
+if test "$ac_dir" != .; then
+  ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
+  # A "../" for each directory in $ac_dir_suffix.
+  ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
+else
+  ac_dir_suffix= ac_top_builddir=
+fi
+
+case $srcdir in
+  .)  # No --srcdir option.  We are building in place.
+    ac_srcdir=.
+    if test -z "$ac_top_builddir"; then
+       ac_top_srcdir=.
+    else
+       ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
+    fi ;;
+  [\\/]* | ?:[\\/]* )  # Absolute path.
+    ac_srcdir=$srcdir$ac_dir_suffix;
+    ac_top_srcdir=$srcdir ;;
+  *) # Relative path.
+    ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_builddir$srcdir ;;
+esac
+# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be
+# absolute.
+ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd`
+ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd`
+ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd`
+ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd`
+
+
+  case $INSTALL in
+  [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
+  *) ac_INSTALL=$ac_top_builddir$INSTALL ;;
+  esac
+
+  if test x"$ac_file" != x-; then
+    { echo "$as_me:$LINENO: creating $ac_file" >&5
+echo "$as_me: creating $ac_file" >&6;}
+    rm -f "$ac_file"
+  fi
+  # Let's still pretend it is `configure' which instantiates (i.e., don't
+  # use $as_me), people would be surprised to read:
+  #    /* config.h.  Generated by config.status.  */
+  if test x"$ac_file" = x-; then
+    configure_input=
+  else
+    configure_input="$ac_file.  "
+  fi
+  configure_input=$configure_input"Generated from `echo $ac_file_in |
+                                     sed 's,.*/,,'` by configure."
+
+  # First look for the input files in the build tree, otherwise in the
+  # src tree.
+  ac_file_inputs=`IFS=:
+    for f in $ac_file_in; do
+      case $f in
+      -) echo $tmp/stdin ;;
+      [\\/$]*)
+         # Absolute (can't be DOS-style, as IFS=:)
+         test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+   { (exit 1); exit 1; }; }
+         echo $f;;
+      *) # Relative
+         if test -f "$f"; then
+           # Build tree
+           echo $f
+         elif test -f "$srcdir/$f"; then
+           # Source tree
+           echo $srcdir/$f
+         else
+           # /dev/null tree
+           { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+   { (exit 1); exit 1; }; }
+         fi;;
+      esac
+    done` || { (exit 1); exit 1; }
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF
+  sed "$ac_vpsub
+$extrasub
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+:t
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+s, at configure_input@,$configure_input,;t t
+s, at srcdir@,$ac_srcdir,;t t
+s, at abs_srcdir@,$ac_abs_srcdir,;t t
+s, at top_srcdir@,$ac_top_srcdir,;t t
+s, at abs_top_srcdir@,$ac_abs_top_srcdir,;t t
+s, at builddir@,$ac_builddir,;t t
+s, at abs_builddir@,$ac_abs_builddir,;t t
+s, at top_builddir@,$ac_top_builddir,;t t
+s, at abs_top_builddir@,$ac_abs_top_builddir,;t t
+s, at INSTALL@,$ac_INSTALL,;t t
+" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out
+  rm -f $tmp/stdin
+  if test x"$ac_file" != x-; then
+    mv $tmp/out $ac_file
+  else
+    cat $tmp/out
+    rm -f $tmp/out
+  fi
+
+done
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+
+#
+# CONFIG_HEADER section.
+#
+
+# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
+# NAME is the cpp macro being defined and VALUE is the value it is being given.
+#
+# ac_d sets the value in "#define NAME VALUE" lines.
+ac_dA='s,^\([ 	]*\)#\([ 	]*define[ 	][ 	]*\)'
+ac_dB='[ 	].*$,\1#\2'
+ac_dC=' '
+ac_dD=',;t'
+# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
+ac_uA='s,^\([ 	]*\)#\([ 	]*\)undef\([ 	][ 	]*\)'
+ac_uB='$,\1#\2define\3'
+ac_uC=' '
+ac_uD=',;t'
+
+for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue
+  # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+  case $ac_file in
+  - | *:- | *:-:* ) # input from stdin
+        cat >$tmp/stdin
+        ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+        ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+  *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+        ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+  * )   ac_file_in=$ac_file.in ;;
+  esac
+
+  test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5
+echo "$as_me: creating $ac_file" >&6;}
+
+  # First look for the input files in the build tree, otherwise in the
+  # src tree.
+  ac_file_inputs=`IFS=:
+    for f in $ac_file_in; do
+      case $f in
+      -) echo $tmp/stdin ;;
+      [\\/$]*)
+         # Absolute (can't be DOS-style, as IFS=:)
+         test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+   { (exit 1); exit 1; }; }
+         echo $f;;
+      *) # Relative
+         if test -f "$f"; then
+           # Build tree
+           echo $f
+         elif test -f "$srcdir/$f"; then
+           # Source tree
+           echo $srcdir/$f
+         else
+           # /dev/null tree
+           { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+   { (exit 1); exit 1; }; }
+         fi;;
+      esac
+    done` || { (exit 1); exit 1; }
+  # Remove the trailing spaces.
+  sed 's/[ 	]*$//' $ac_file_inputs >$tmp/in
+
+_ACEOF
+
+# Transform confdefs.h into two sed scripts, `conftest.defines' and
+# `conftest.undefs', that substitutes the proper values into
+# config.h.in to produce config.h.  The first handles `#define'
+# templates, and the second `#undef' templates.
+# And first: Protect against being on the right side of a sed subst in
+# config.status.  Protect against being in an unquoted here document
+# in config.status.
+rm -f conftest.defines conftest.undefs
+# Using a here document instead of a string reduces the quoting nightmare.
+# Putting comments in sed scripts is not portable.
+#
+# `end' is used to avoid that the second main sed command (meant for
+# 0-ary CPP macros) applies to n-ary macro definitions.
+# See the Autoconf documentation for `clear'.
+cat >confdef2sed.sed <<\_ACEOF
+s/[\\&,]/\\&/g
+s,[\\$`],\\&,g
+t clear
+: clear
+s,^[ 	]*#[ 	]*define[ 	][ 	]*\([^ 	(][^ 	(]*\)\(([^)]*)\)[ 	]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp
+t end
+s,^[ 	]*#[ 	]*define[ 	][ 	]*\([^ 	][^ 	]*\)[ 	]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp
+: end
+_ACEOF
+# If some macros were called several times there might be several times
+# the same #defines, which is useless.  Nevertheless, we may not want to
+# sort them, since we want the *last* AC-DEFINE to be honored.
+uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines
+sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs
+rm -f confdef2sed.sed
+
+# This sed command replaces #undef with comments.  This is necessary, for
+# example, in the case of _POSIX_SOURCE, which is predefined and required
+# on some systems where configure will not decide to define it.
+cat >>conftest.undefs <<\_ACEOF
+s,^[ 	]*#[ 	]*undef[ 	][ 	]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */,
+_ACEOF
+
+# Break up conftest.defines because some shells have a limit on the size
+# of here documents, and old seds have small limits too (100 cmds).
+echo '  # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS
+echo '  if grep "^[ 	]*#[ 	]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS
+echo '  # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS
+echo '  :' >>$CONFIG_STATUS
+rm -f conftest.tail
+while grep . conftest.defines >/dev/null
+do
+  # Write a limited-size here document to $tmp/defines.sed.
+  echo '  cat >$tmp/defines.sed <<CEOF' >>$CONFIG_STATUS
+  # Speed up: don't consider the non `#define' lines.
+  echo '/^[ 	]*#[ 	]*define/!b' >>$CONFIG_STATUS
+  # Work around the forget-to-reset-the-flag bug.
+  echo 't clr' >>$CONFIG_STATUS
+  echo ': clr' >>$CONFIG_STATUS
+  sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS
+  echo 'CEOF
+  sed -f $tmp/defines.sed $tmp/in >$tmp/out
+  rm -f $tmp/in
+  mv $tmp/out $tmp/in
+' >>$CONFIG_STATUS
+  sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail
+  rm -f conftest.defines
+  mv conftest.tail conftest.defines
+done
+rm -f conftest.defines
+echo '  fi # grep' >>$CONFIG_STATUS
+echo >>$CONFIG_STATUS
+
+# Break up conftest.undefs because some shells have a limit on the size
+# of here documents, and old seds have small limits too (100 cmds).
+echo '  # Handle all the #undef templates' >>$CONFIG_STATUS
+rm -f conftest.tail
+while grep . conftest.undefs >/dev/null
+do
+  # Write a limited-size here document to $tmp/undefs.sed.
+  echo '  cat >$tmp/undefs.sed <<CEOF' >>$CONFIG_STATUS
+  # Speed up: don't consider the non `#undef'
+  echo '/^[ 	]*#[ 	]*undef/!b' >>$CONFIG_STATUS
+  # Work around the forget-to-reset-the-flag bug.
+  echo 't clr' >>$CONFIG_STATUS
+  echo ': clr' >>$CONFIG_STATUS
+  sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS
+  echo 'CEOF
+  sed -f $tmp/undefs.sed $tmp/in >$tmp/out
+  rm -f $tmp/in
+  mv $tmp/out $tmp/in
+' >>$CONFIG_STATUS
+  sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail
+  rm -f conftest.undefs
+  mv conftest.tail conftest.undefs
+done
+rm -f conftest.undefs
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+  # Let's still pretend it is `configure' which instantiates (i.e., don't
+  # use $as_me), people would be surprised to read:
+  #    /* config.h.  Generated by config.status.  */
+  if test x"$ac_file" = x-; then
+    echo "/* Generated by configure.  */" >$tmp/config.h
+  else
+    echo "/* $ac_file.  Generated by configure.  */" >$tmp/config.h
+  fi
+  cat $tmp/in >>$tmp/config.h
+  rm -f $tmp/in
+  if test x"$ac_file" != x-; then
+    if diff $ac_file $tmp/config.h >/dev/null 2>&1; then
+      { echo "$as_me:$LINENO: $ac_file is unchanged" >&5
+echo "$as_me: $ac_file is unchanged" >&6;}
+    else
+      ac_dir=`(dirname "$ac_file") 2>/dev/null ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+         X"$ac_file" : 'X\(//\)[^/]' \| \
+         X"$ac_file" : 'X\(//\)$' \| \
+         X"$ac_file" : 'X\(/\)' \| \
+         .     : '\(.\)' 2>/dev/null ||
+echo X"$ac_file" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+  	  /^X\(\/\/\)$/{ s//\1/; q; }
+  	  /^X\(\/\).*/{ s//\1/; q; }
+  	  s/.*/./; q'`
+      { if $as_mkdir_p; then
+    mkdir -p "$ac_dir"
+  else
+    as_dir="$ac_dir"
+    as_dirs=
+    while test ! -d "$as_dir"; do
+      as_dirs="$as_dir $as_dirs"
+      as_dir=`(dirname "$as_dir") 2>/dev/null ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+         X"$as_dir" : 'X\(//\)[^/]' \| \
+         X"$as_dir" : 'X\(//\)$' \| \
+         X"$as_dir" : 'X\(/\)' \| \
+         .     : '\(.\)' 2>/dev/null ||
+echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+  	  /^X\(\/\/\)$/{ s//\1/; q; }
+  	  /^X\(\/\).*/{ s//\1/; q; }
+  	  s/.*/./; q'`
+    done
+    test ! -n "$as_dirs" || mkdir $as_dirs
+  fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
+echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
+   { (exit 1); exit 1; }; }; }
+
+      rm -f $ac_file
+      mv $tmp/config.h $ac_file
+    fi
+  else
+    cat $tmp/config.h
+    rm -f $tmp/config.h
+  fi
+_am_stamp_count=`expr ${_am_stamp_count-0} + 1`
+echo "timestamp for $ac_file" >`(dirname $ac_file) 2>/dev/null ||
+$as_expr X$ac_file : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+         X$ac_file : 'X\(//\)[^/]' \| \
+         X$ac_file : 'X\(//\)$' \| \
+         X$ac_file : 'X\(/\)' \| \
+         .     : '\(.\)' 2>/dev/null ||
+echo X$ac_file |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+  	  /^X\(\/\/\)$/{ s//\1/; q; }
+  	  /^X\(\/\).*/{ s//\1/; q; }
+  	  s/.*/./; q'`/stamp-h$_am_stamp_count
+done
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+
+#
+# CONFIG_COMMANDS section.
+#
+for ac_file in : $CONFIG_COMMANDS; do test "x$ac_file" = x: && continue
+  ac_dest=`echo "$ac_file" | sed 's,:.*,,'`
+  ac_source=`echo "$ac_file" | sed 's,[^:]*:,,'`
+  ac_dir=`(dirname "$ac_dest") 2>/dev/null ||
+$as_expr X"$ac_dest" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+         X"$ac_dest" : 'X\(//\)[^/]' \| \
+         X"$ac_dest" : 'X\(//\)$' \| \
+         X"$ac_dest" : 'X\(/\)' \| \
+         .     : '\(.\)' 2>/dev/null ||
+echo X"$ac_dest" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+  	  /^X\(\/\/\)$/{ s//\1/; q; }
+  	  /^X\(\/\).*/{ s//\1/; q; }
+  	  s/.*/./; q'`
+  ac_builddir=.
+
+if test "$ac_dir" != .; then
+  ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
+  # A "../" for each directory in $ac_dir_suffix.
+  ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
+else
+  ac_dir_suffix= ac_top_builddir=
+fi
+
+case $srcdir in
+  .)  # No --srcdir option.  We are building in place.
+    ac_srcdir=.
+    if test -z "$ac_top_builddir"; then
+       ac_top_srcdir=.
+    else
+       ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
+    fi ;;
+  [\\/]* | ?:[\\/]* )  # Absolute path.
+    ac_srcdir=$srcdir$ac_dir_suffix;
+    ac_top_srcdir=$srcdir ;;
+  *) # Relative path.
+    ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_builddir$srcdir ;;
+esac
+# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be
+# absolute.
+ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd`
+ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd`
+ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd`
+ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd`
+
+
+  { echo "$as_me:$LINENO: executing $ac_dest commands" >&5
+echo "$as_me: executing $ac_dest commands" >&6;}
+  case $ac_dest in
+    depfiles ) test x"$AMDEP_TRUE" != x"" || for mf in $CONFIG_FILES; do
+  # Strip MF so we end up with the name of the file.
+  mf=`echo "$mf" | sed -e 's/:.*$//'`
+  # Check whether this is an Automake generated Makefile or not.
+  # We used to match only the files named `Makefile.in', but
+  # some people rename them; so instead we look at the file content.
+  # Grep'ing the first line is not enough: some people post-process
+  # each Makefile.in and add a new line on top of each file to say so.
+  # So let's grep whole file.
+  if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then
+    dirpart=`(dirname "$mf") 2>/dev/null ||
+$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+         X"$mf" : 'X\(//\)[^/]' \| \
+         X"$mf" : 'X\(//\)$' \| \
+         X"$mf" : 'X\(/\)' \| \
+         .     : '\(.\)' 2>/dev/null ||
+echo X"$mf" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+  	  /^X\(\/\/\)$/{ s//\1/; q; }
+  	  /^X\(\/\).*/{ s//\1/; q; }
+  	  s/.*/./; q'`
+  else
+    continue
+  fi
+  grep '^DEP_FILES *= *[^ #]' < "$mf" > /dev/null || continue
+  # Extract the definition of DEP_FILES from the Makefile without
+  # running `make'.
+  DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"`
+  test -z "$DEPDIR" && continue
+  # When using ansi2knr, U may be empty or an underscore; expand it
+  U=`sed -n -e '/^U = / s///p' < "$mf"`
+  test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR"
+  # We invoke sed twice because it is the simplest approach to
+  # changing $(DEPDIR) to its actual value in the expansion.
+  for file in `sed -n -e '
+    /^DEP_FILES = .*\\\\$/ {
+      s/^DEP_FILES = //
+      :loop
+	s/\\\\$//
+	p
+	n
+	/\\\\$/ b loop
+      p
+    }
+    /^DEP_FILES = / s/^DEP_FILES = //p' < "$mf" | \
+       sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
+    # Make sure the directory exists.
+    test -f "$dirpart/$file" && continue
+    fdir=`(dirname "$file") 2>/dev/null ||
+$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+         X"$file" : 'X\(//\)[^/]' \| \
+         X"$file" : 'X\(//\)$' \| \
+         X"$file" : 'X\(/\)' \| \
+         .     : '\(.\)' 2>/dev/null ||
+echo X"$file" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+  	  /^X\(\/\/\)$/{ s//\1/; q; }
+  	  /^X\(\/\).*/{ s//\1/; q; }
+  	  s/.*/./; q'`
+    { if $as_mkdir_p; then
+    mkdir -p $dirpart/$fdir
+  else
+    as_dir=$dirpart/$fdir
+    as_dirs=
+    while test ! -d "$as_dir"; do
+      as_dirs="$as_dir $as_dirs"
+      as_dir=`(dirname "$as_dir") 2>/dev/null ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+         X"$as_dir" : 'X\(//\)[^/]' \| \
+         X"$as_dir" : 'X\(//\)$' \| \
+         X"$as_dir" : 'X\(/\)' \| \
+         .     : '\(.\)' 2>/dev/null ||
+echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+  	  /^X\(\/\/\)$/{ s//\1/; q; }
+  	  /^X\(\/\).*/{ s//\1/; q; }
+  	  s/.*/./; q'`
+    done
+    test ! -n "$as_dirs" || mkdir $as_dirs
+  fi || { { echo "$as_me:$LINENO: error: cannot create directory $dirpart/$fdir" >&5
+echo "$as_me: error: cannot create directory $dirpart/$fdir" >&2;}
+   { (exit 1); exit 1; }; }; }
+
+    # echo "creating $dirpart/$file"
+    echo '# dummy' > "$dirpart/$file"
+  done
+done
+ ;;
+  esac
+done
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+
+{ (exit 0); exit 0; }
+_ACEOF
+chmod +x $CONFIG_STATUS
+ac_clean_files=$ac_clean_files_save
+
+
+# configure is writing to config.log, and then calls config.status.
+# config.status does its own redirection, appending to config.log.
+# Unfortunately, on DOS this fails, as config.log is still kept open
+# by configure, so config.status won't be able to write to it; its
+# output is simply discarded.  So we exec the FD to /dev/null,
+# effectively closing config.log, so it can be properly (re)opened and
+# appended to by config.status.  When coming back to configure, we
+# need to make the FD available again.
+if test "$no_create" != yes; then
+  ac_cs_success=:
+  ac_config_status_args=
+  test "$silent" = yes &&
+    ac_config_status_args="$ac_config_status_args --quiet"
+  exec 5>/dev/null
+  $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
+  exec 5>>config.log
+  # Use ||, not &&, to avoid exiting from the if with $? = 1, which
+  # would make configure fail if this is the last instruction.
+  $ac_cs_success || { (exit 1); exit 1; }
+fi
+


Property changes on: experimental/j/Elphel333/rtp/daemon/rtp/configure
___________________________________________________________________
Name: svn:executable
   + 

Added: experimental/j/Elphel333/rtp/daemon/rtp/configure.in
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/configure.in	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/configure.in	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,244 @@
+dnl Process this file with autoconf to produce a configure script.
+
+AC_INIT(base64.c)
+AM_CONFIG_HEADER(uclconf.h:config.h.in)
+
+AM_INIT_AUTOMAKE(uclrtp, 1.2.8)
+AC_CANONICAL_HOST
+AC_CANONICAL_TARGET
+
+AC_PROG_CC
+AC_PROG_CPP
+AM_PROG_LIBTOOL
+AC_PROG_LIBTOOL
+
+AC_HEADER_STDC
+AC_HEADER_SYS_WAIT
+AC_CHECK_HEADERS(sys/time.h)
+if test "$ac_cv_header_sys_time_h" = "yes"; then
+	AC_HEADER_TIME
+fi
+AC_C_CONST
+AC_TYPE_SIZE_T
+
+AC_CHECK_HEADERS(stropts.h sys/filio.h)
+AC_CHECK_HEADERS(stdint.h inttypes.h)
+
+###############################################################################
+# Check for standard size types.  The defaults are only valid on some
+# systems so we hope that <inttypes.h> exists when they're wrong.
+AC_CHECK_TYPE(int8_t,  signed char)
+AC_CHECK_TYPE(int16_t, short)
+AC_CHECK_TYPE(int32_t, long)
+AC_CHECK_TYPE(int64_t, long long)
+
+# Some systems have these in <stdint.h>, just to be difficult...
+AC_CACHE_CHECK(for uint8_t in <stdint.h>, ucl_cv_uint8_t_in_stdint_h,
+	AC_EGREP_HEADER(uint8_t,
+			stdint.h,
+			ucl_cv_uint8_t_in_stdint_h=yes,
+			ucl_cv_uint8_t_in_stdint_h=no))
+if test $ucl_cv_uint8_t_in_stdint_h = "no"
+then
+	 AC_CHECK_TYPE(uint8_t,  unsigned char)
+fi
+
+AC_CACHE_CHECK(for uint16_t in <stdint.h>, ucl_cv_uint16_t_in_stdint_h,
+	AC_EGREP_HEADER(uint16_t,
+			stdint.h,
+			ucl_cv_uint16_t_in_stdint_h=yes,
+			ucl_cv_uint16_t_in_stdint_h=no))
+if test $ucl_cv_uint16_t_in_stdint_h = "no"
+then
+	 AC_CHECK_TYPE(uint16_t,  unsigned short)
+fi
+
+AC_CACHE_CHECK(for uint32_t in <stdint.h>, ucl_cv_uint32_t_in_stdint_h,
+	AC_EGREP_HEADER(uint32_t,
+			stdint.h,
+			ucl_cv_uint32_t_in_stdint_h=yes,
+			ucl_cv_uint32_t_in_stdint_h=no))
+if test $ucl_cv_uint32_t_in_stdint_h = "no"
+then
+	 AC_CHECK_TYPE(uint32_t,  unsigned int)
+fi
+
+###############################################################################
+# The following two macros cause autoconf to complain.
+AC_C_BIGENDIAN
+AC_C_CHAR_UNSIGNED
+#
+# Some of the codecs in rat don't with with unsigned characters. 
+# Force the compiler to use signed chars, to be consistent.
+if test $ac_cv_c_char_unsigned = yes
+then
+	if test "$GCC" = yes
+	then
+		CFLAGS="$CFLAGS -fsigned-char"
+	else
+		case "$host_os" in
+		# I don't know when "-signed" was added to IRIX CC
+		# so err on the side of using it.
+		irix*)	CFLAGS="$CFLAGS -signed"
+			;;
+		# need e.g. --force-signed-chars=-signed
+		*)	AC_MSG_ERROR([I don't know how to force signed chars])
+			;;
+		esac
+	fi
+fi
+#  __CHAR_UNSIGNED__ will be defined; hope this is OK.
+
+###############################################################################
+# The following causes autoconf to complain.
+AC_CHECK_FILE(/dev/urandom,AC_DEFINE(HAVE_DEV_URANDOM))
+
+# If more files than mbus.c use vsnprintf, split it out into
+# vsnprintf.c and add it to AC_REPLACE_FUNCS
+# AC_CHECK_FUNC(vsnprintf,,AC_DEFINE(NEED_VSNPRINTF))
+AC_REPLACE_FUNCS(vsnprintf)
+
+###############################################################################
+# If inet_aton is actually needed somewhere, split it out into
+# inet_aton.c and add it to AC_REPLACE_FUNCS 
+#
+# AC_CHECK_FUNC succeeds on our IRIX 6.2 boxes, but it is not 
+# declared anywhere, use egrep header to check (ugh lame, but works)
+
+AC_CHECK_FUNCS(inet_pton inet_ntop inet_aton)
+dnl AC_REPLACE_FUNCS(inet_pton inet_ntop)
+
+AC_SEARCH_LIBS(socket, socket)
+AC_SEARCH_LIBS(inet_addr, nsl)
+
+###############################################################################
+#  -profile
+AC_ARG_ENABLE(profile,
+	[  --enable-profile        enable profiling],
+	[if test $enableval = yes
+	then
+		if test "$GCC" = yes
+		then
+			CFLAGS="$CFLAGS -pg"
+		else
+			AC_ERROR([Don't know how to enable profiling for $CC])
+		fi
+	fi])
+
+#  -bounds
+#       add -fbounds-checking to CFLAGS
+#       add -lcheck to LIBS
+AC_ARG_ENABLE(bounds,
+	[  --enable-bounds         enable bounds checking],
+	[if test $enableval = yes
+	then
+		if test "$GCC" = yes
+		then
+			CFLAGS="$CFLAGS -fbounds-checking"
+			LIBS="$LIBS -lcheck"
+		else
+			AC_ERROR([Don't know how to enable profiling for $CC])
+		fi
+	fi])
+
+# -DDEBUG
+# -DDEBUG_MEM
+# -DNDEBUG
+AC_ARG_ENABLE(debug,
+	[  --enable-debug          enable debug messages and code],
+	[if test $enableval = yes
+	then
+		AC_DEFINE(DEBUG)
+	fi])
+AC_ARG_ENABLE(debug-mem,
+	[  --enable-debug-mem      enable memory debugging code],
+	[if test $enableval = yes
+	then
+		AC_DEFINE(DEBUG_MEM)
+	fi])
+
+###############################################################################
+# IPv6 related configuration options
+
+AC_ARG_ENABLE(ipv6,
+        [  --enable-ipv6           enable ipv6],
+	AC_DEFINE(HAVE_IPv6))
+
+AC_ARG_ENABLE(kame-ipv6,
+	[  --enable-kame-ipv6      enable kame implementation of ipv6],
+	[
+		AC_DEFINE(HAVE_IPv6)
+		LIBS="$LIBS -L/usr/local/v6/lib -linet6"
+	])
+
+# Test below are IPv6 specific.  Their result has no bearing if HAVE_IPv6 is
+# not defined.  They are kept outside IPv6 enable check to keep code readable.
+
+AC_CACHE_CHECK(for getipnodebyname in <netdb.h>, ucl_cv_getipnodebyname_in_netdb_h,
+	[AC_EGREP_HEADER(getipnodebyname,
+		netdb.h,
+		ucl_cv_getipnodebyname_in_netdb_h=yes,	
+		ucl_cv_getipnodebyname_in_netdb_h=no)])
+if test $ucl_cv_getipnodebyname_in_netdb_h
+then
+	AC_DEFINE(HAVE_GETIPNODEBYNAME) 
+fi
+
+AC_CHECK_HEADERS(netinet6/in6.h)
+AC_CHECK_HEADERS(netinet/ip6.h)
+
+AC_CACHE_CHECK(for struct addrinfo in <netdb.h>, ucl_cv_st_addrinfo_in_netdb_h,
+	[AC_EGREP_HEADER(addrinfo,
+		netdb.h,
+		ucl_cv_st_addrinfo_in_netdb_h=yes,	
+		ucl_cv_st_addrinfo_in_netdb_h=no)])
+if test $ucl_cv_st_addrinfo_in_netdb_h
+then
+	AC_DEFINE(HAVE_ST_ADDRINFO) 
+fi
+
+AC_CACHE_CHECK(for sin6_len in struct sockaddr_in6, ucl_cv_sin6_len,
+	[AC_TRY_COMPILE([
+		#ifdef HAVE_NETINET6_IN6_H
+		#include <netinet6/in6.h>
+		#else
+		#ifdef HAVE_NETINET_IP6_H
+		#include <netinet/ip6.h>
+		#else
+		#include <netinet/in.h>
+		#endif
+		#endif /* HAVE_NETINET_IN6_H */
+	],[
+		struct sockaddr_in6	s_in;
+		s_in.sin6_len = 0;
+	],
+		ucl_cv_sin6_len=yes,	
+		ucl_cv_sin6_len=no
+	)])
+if test $ucl_cv_sin6_len = yes
+then
+	AC_DEFINE(HAVE_SIN6_LEN) 
+fi
+
+###############################################################################
+# Check whether gtk-doc is installed
+
+AC_CHECK_PROG(GTKDOC, gtkdoc-scan, yes, no, $PATH)
+if test "$GTKDOC" = yes 
+then
+	OPTDOC=doc
+else
+	OPTDOC=
+fi
+AC_SUBST(OPTDOC)
+
+###############################################################################
+# GCC-specific warning flags
+if test "$GCC" = yes
+then
+        CFLAGS="$CFLAGS -W -Wall -Wwrite-strings -Wbad-function-cast -Wmissing-prototypes -Wmissing-declarations -Werror"
+fi
+
+###############################################################################
+# Done, create the output files....
+AC_OUTPUT(Makefile win32/Makefile)

Added: experimental/j/Elphel333/rtp/daemon/rtp/crypt_random.c
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/crypt_random.c	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/crypt_random.c	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 1993 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the Computer Systems
+ *	Engineering Group at Lawrence Berkeley Laboratory.
+ * 4. Neither the name of the University nor of the Laboratory may be used
+ *    to endorse or promote products derived from this software without
+ *    specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * LBL random number generator.
+ *
+ * Written by Steve McCanne & Chris Torek (mccanne at ee.lbl.gov,
+ * torek at ee.lbl.gov), November, 1992.
+ *
+ * This implementation is based on ``Two Fast Implementations of
+ * the "Minimal Standard" Random Number Generator", David G. Carta,
+ * Communications of the ACM, Jan 1990, Vol 33 No 1.
+ */
+
+#include "config_win32.h"
+#include "config_unix.h"
+#include "crypt_random.h"
+
+static uint32_t randseed = 1;
+
+void
+lbl_srandom(uint32_t seed)
+{
+	randseed = seed;
+}
+
+uint32_t
+lbl_random(void)
+{
+#ifdef HAVE_DEV_URANDOM
+	int	fd, res, l;
+
+	fd = open("/dev/urandom", O_RDONLY);
+	if (fd == -1) {
+		perror("Cannot open random sequence generator");
+		abort();
+	}
+	l = read(fd, &res, sizeof(res));
+	if (l != sizeof(res)) {
+		perror("Cannot read random data");
+		abort();
+	}
+	close(fd);
+	return res;
+#else
+	register uint32_t x = randseed;
+	register uint32_t hi, lo, t;
+
+	hi = x / 127773;
+	lo = x % 127773;
+	t = 16807 * lo - 2836 * hi;
+	if (t <= 0)
+		t += 0x7fffffff;
+	randseed = t;
+	return (t);
+#endif
+}
+

Added: experimental/j/Elphel333/rtp/daemon/rtp/crypt_random.h
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/crypt_random.h	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/crypt_random.h	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 1993 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the Computer Systems
+ *	Engineering Group at Lawrence Berkeley Laboratory.
+ * 4. Neither the name of the University nor of the Laboratory may be used
+ *    to endorse or promote products derived from this software without
+ *    specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * LBL random number generator.
+ *
+ * Written by Steve McCanne & Chris Torek (mccanne at ee.lbl.gov,
+ * torek at ee.lbl.gov), November, 1992.
+ *
+ * This implementation is based on ``Two Fast Implementations of
+ * the "Minimal Standard" Random Number Generator", David G. Carta,
+ * Communications of the ACM, Jan 1990, Vol 33 No 1.
+ */
+
+void      lbl_srandom(uint32_t seed);
+uint32_t lbl_random(void);
+

Added: experimental/j/Elphel333/rtp/daemon/rtp/debug.c
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/debug.c	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/debug.c	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,250 @@
+/*
+ * FILE:    debug.c
+ * PROGRAM: RAT
+ * AUTHORS: Isidor Kouvelas 
+ *          Colin Perkins 
+ *          Mark Handley 
+ *          Orion Hodson
+ *          Jerry Isdale
+ * 
+ * $Revision: 1.1.1.1 $
+ * $Date: 2005/03/18 09:17:35 $
+ *
+ * Copyright (c) 1995-2000 University College London
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, is permitted provided that the following conditions 
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by the Computer Science
+ *      Department at University College London
+ * 4. Neither the name of the University nor of the Department may be used
+ *    to endorse or promote products derived from this software without
+ *    specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "config_unix.h"
+#include "config_win32.h"
+#include "gettimeofday.h"
+#include "debug.h"
+
+void _dprintf(const char *format, ...)
+{
+#ifdef DEBUG
+#ifdef WIN32
+        char msg[65535];
+        va_list ap;
+        
+        va_start(ap, format);
+	_vsnprintf(msg, 65535, format, ap);
+        va_end(ap);
+        OutputDebugString(msg);
+#else 
+        va_list ap;
+ 
+        va_start(ap, format);
+        vfprintf(stderr, format, ap);
+        va_end(ap);
+#endif /* WIN32 */
+#else
+        UNUSED (format);
+#endif /* DEBUG */
+}
+
+/**
+ * debug_dump:
+ * @lp: pointer to memory region.
+ * @len: length of memory region in bytes.
+ * 
+ * Writes a dump of a memory region to stdout.  The dump contains a
+ * hexadecimal and an ascii representation of the memory region.
+ * 
+ **/
+void debug_dump(void*lp, long len)
+{
+   char * p;
+   long i, j, start;
+   char Buff[80];
+   char stuffBuff[10];
+   char tmpBuf[10];
+  
+   _dprintf("Dump of %ld=%lx bytes\n",len, len);
+   start = 0L;
+   while (start < len)
+   {
+    /* start line with pointer position key */
+      p = (char*)lp + start;
+      sprintf(Buff,"%p: ",p);
+  
+    /* display each character as hex value */
+      for (i=start, j=0; j < 16; p++,i++, j++)
+      {
+         if (i < len)
+         {
+            sprintf(tmpBuf,"%X",((int)(*p) & 0xFF));
+  
+            if (strlen((char *)tmpBuf) < 2)
+            {
+               stuffBuff[0] = '0';
+               stuffBuff[1] = tmpBuf[0];
+               stuffBuff[2] = ' ';
+               stuffBuff[3] = '\0';
+            } else
+            {
+               stuffBuff[0] = tmpBuf[0];
+               stuffBuff[1] = tmpBuf[1];
+               stuffBuff[2] = ' ';
+               stuffBuff[3] = '\0';
+            }
+            strcat(Buff, stuffBuff);
+         } else
+            strcat(Buff," ");
+         if (j == 7) /* space between groups of 8 */
+            strcat(Buff," ");
+      }
+  
+    /* fill out incomplete lines */
+      for(;j<16;j++)
+      {
+         strcat(Buff,"   ");
+         if (j == 7)
+            strcat(Buff," ");
+      }
+      strcat(Buff,"  ");
+  
+    /* display each character as character value */
+      for (i=start,j=0,p=(char*)lp+start;
+         (i < len && j < 16); p++,i++, j++)
+      {
+         if ( ((*p) >= ' ') && ((*p) <= '~') )   /* test displayable */
+            sprintf(tmpBuf,"%c", *p);
+         else
+            sprintf(tmpBuf,"%c", '.');
+         strcat(Buff,tmpBuf);
+         if (j == 7)   /* space between groups of 8 */
+            strcat(Buff," ");
+      }
+      _dprintf("%s\n", Buff);
+      start = i;  /* next line starting byte */
+   }
+}
+
+/**
+ * debug_set_core_dir:
+ * @argv0: the application path (usually argv[0] in main()).
+ * 
+ * Creates a directory with the application name and makes it the
+ * current working directory.  
+ * 
+ * This function exists because some unix variants use the name 'core'
+ * for core dump files.  When an application uses multiple processes,
+ * this can be problematic if the failure of one process leads to the
+ * failure of another because the dependent process 'core' file will
+ * overwrite the core of the failing process.
+ **/
+void debug_set_core_dir(const char *argv0)
+{
+#if defined(DEBUG) && !defined(WIN32)
+        struct stat s;
+        char coredir[64];
+        const char *appname;
+
+        appname = strrchr(argv0, '/');
+        if (appname == NULL) {
+                appname = argv0;
+        } else {
+                appname = appname + 1;
+        }
+
+        /* Should check length of appname, but this is debug code   */
+        /* and developers should know better than to have 64 char   */
+        /* app name.                                                */
+        sprintf(coredir, "core-%s", appname);
+
+        mkdir(coredir, S_IRWXU);
+        if (stat(coredir, &s) != 0) {
+                debug_msg("Could not stat %s\n", coredir);
+                return;
+        }
+        if (!S_ISDIR(s.st_mode)) {
+                debug_msg("Not a directory: %s\n", coredir);
+                return;
+        }
+        if (!(s.st_mode & S_IWUSR) || !(s.st_mode & S_IXUSR)) {
+                debug_msg("Cannot write in or change to %s\n", coredir);
+                return;
+        }
+        if (chdir(coredir)) {
+                perror(coredir);
+        }
+#endif /* DEBUG */
+        UNUSED(argv0);
+}
+
+static int rtp_debug_level =
+#ifdef DEBUG
+LOG_DEBUG;
+#else
+LOG_ERR;
+#endif
+
+void rtp_set_loglevel (int loglevel)
+{
+  rtp_debug_level = loglevel;
+}
+static rtp_error_msg_func_t error_msg_func = NULL;
+
+void rtp_set_error_msg_func (rtp_error_msg_func_t func)
+{
+  error_msg_func = func;
+}
+void rtp_message (int loglevel, const char *fmt, ...)
+{
+  va_list ap;
+  if (loglevel <= rtp_debug_level) {
+    va_start(ap, fmt);
+    if (error_msg_func != NULL) {
+      (error_msg_func)(loglevel, "rtp", fmt, ap);
+    } else {
+ #if _WIN32 && _DEBUG
+	  char msg[1024];
+
+      _vsnprintf(msg, 1024, fmt, ap);
+      OutputDebugString(msg);
+      OutputDebugString("\n");
+#else
+      struct timeval thistime;
+      char buffer[80];
+      time_t secs;
+
+      gettimeofday(&thistime, NULL);
+      // To add date, add %a %b %d to strftime
+      secs = thistime.tv_sec;
+      strftime(buffer, sizeof(buffer), "%X", localtime(&secs));
+      printf("%s.%03ld-rtp-%d: ",
+	     buffer, (unsigned long)thistime.tv_usec / 1000, loglevel);
+      vprintf(fmt, ap);
+      printf("\n");
+#endif
+    }
+    va_end(ap);
+  }
+}

Added: experimental/j/Elphel333/rtp/daemon/rtp/debug.h
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/debug.h	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/debug.h	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,71 @@
+/*
+ * FILE:    debug.h
+ * PROGRAM: RAT
+ * AUTHOR:  Isidor Kouvelas + Colin Perkins + Mark Handley + Orion Hodson
+ * 
+ * $Revision: 1.1.1.1 $
+ * $Date: 2005/03/18 09:17:35 $
+ *
+ * Copyright (c) 1995-2000 University College London
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, is permitted provided that the following conditions 
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by the Computer Science
+ *      Department at University College London
+ * 4. Neither the name of the University nor of the Department may be used
+ *    to endorse or promote products derived from this software without
+ *    specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _RAT_DEBUG_H
+#define _RAT_DEBUG_H
+
+#define UNUSED(x)	(x=x)
+#define debug_msg	_dprintf("%d:%s:%d ", getpid(), __FILE__, __LINE__), _dprintf
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+  void rtp_message(int loglevel, const char *fmt, ...)
+#ifndef _WIN32
+     __attribute__((format(__printf__, 2, 3)));
+#else
+     ;
+#endif
+typedef void (*rtp_error_msg_func_t)(int loglevel,
+				     const char *lib,
+				     const char *fmt,
+				     va_list ap);
+  void rtp_set_error_msg_func(rtp_error_msg_func_t func);
+
+  void rtp_set_loglevel(int loglevel);
+void _dprintf(const char *format, ...);
+void debug_dump(void*lp, long len);
+void debug_set_core_dir(const char *argv0);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif

Added: experimental/j/Elphel333/rtp/daemon/rtp/depcomp
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/depcomp	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/depcomp	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,423 @@
+#! /bin/sh
+
+# depcomp - compile a program generating dependencies as side-effects
+# Copyright 1999, 2000 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Originally written by Alexandre Oliva <oliva at dcc.unicamp.br>.
+
+if test -z "$depmode" || test -z "$source" || test -z "$object"; then
+  echo "depcomp: Variables source, object and depmode must be set" 1>&2
+  exit 1
+fi
+# `libtool' can also be set to `yes' or `no'.
+
+if test -z "$depfile"; then
+   base=`echo "$object" | sed -e 's,^.*/,,' -e 's,\.\([^.]*\)$,.P\1,'`
+   dir=`echo "$object" | sed 's,/.*$,/,'`
+   if test "$dir" = "$object"; then
+      dir=
+   fi
+   # FIXME: should be _deps on DOS.
+   depfile="$dir.deps/$base"
+fi
+
+tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
+
+rm -f "$tmpdepfile"
+
+# Some modes work just like other modes, but use different flags.  We
+# parameterize here, but still list the modes in the big case below,
+# to make depend.m4 easier to write.  Note that we *cannot* use a case
+# here, because this file can only contain one case statement.
+if test "$depmode" = hp; then
+  # HP compiler uses -M and no extra arg.
+  gccflag=-M
+  depmode=gcc
+fi
+
+if test "$depmode" = dashXmstdout; then
+   # This is just like dashmstdout with a different argument.
+   dashmflag=-xM
+   depmode=dashmstdout
+fi
+
+case "$depmode" in
+gcc3)
+## gcc 3 implements dependency tracking that does exactly what
+## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
+## it if -MD -MP comes after the -MF stuff.  Hmm.
+  "$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  mv "$tmpdepfile" "$depfile"
+  ;;
+
+gcc)
+## There are various ways to get dependency output from gcc.  Here's
+## why we pick this rather obscure method:
+## - Don't want to use -MD because we'd like the dependencies to end
+##   up in a subdir.  Having to rename by hand is ugly.
+##   (We might end up doing this anyway to support other compilers.)
+## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
+##   -MM, not -M (despite what the docs say).
+## - Using -M directly means running the compiler twice (even worse
+##   than renaming).
+  if test -z "$gccflag"; then
+    gccflag=-MD,
+  fi
+  "$@" -Wp,"$gccflag$tmpdepfile"
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
+## The second -e expression handles DOS-style file names with drive letters.
+  sed -e 's/^[^:]*: / /' \
+      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
+## This next piece of magic avoids the `deleted header file' problem.
+## The problem is that when a header file which appears in a .P file
+## is deleted, the dependency causes make to die (because there is
+## typically no way to rebuild the header).  We avoid this by adding
+## dummy dependencies for each header file.  Too bad gcc doesn't do
+## this for us directly.
+  tr ' ' '
+' < "$tmpdepfile" |
+## Some versions of gcc put a space before the `:'.  On the theory
+## that the space means something, we add a space to the output as
+## well.
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly.  Breaking it into two sed invocations is a workaround.
+    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+hp)
+  # This case exists only to let depend.m4 do its work.  It works by
+  # looking at the text of this script.  This case will never be run,
+  # since it is checked for above.
+  exit 1
+  ;;
+
+sgi)
+  if test "$libtool" = yes; then
+    "$@" "-Wp,-MDupdate,$tmpdepfile"
+  else
+    "$@" -MDupdate "$tmpdepfile"
+  fi
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+
+  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
+    echo "$object : \\" > "$depfile"
+
+    # Clip off the initial element (the dependent).  Don't try to be
+    # clever and replace this with sed code, as IRIX sed won't handle
+    # lines with more than a fixed number of characters (4096 in
+    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
+    # the IRIX cc adds comments like `#:fec' to the end of the
+    # dependency line.
+    tr ' ' '
+' < "$tmpdepfile" \
+    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
+    tr '
+' ' ' >> $depfile
+    echo >> $depfile
+
+    # The second pass generates a dummy entry for each header file.
+    tr ' ' '
+' < "$tmpdepfile" \
+   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
+   >> $depfile
+  else
+    # The sourcefile does not contain any dependencies, so just
+    # store a dummy comment line, to avoid errors with the Makefile
+    # "include basename.Plo" scheme.
+    echo "#dummy" > "$depfile"
+  fi
+  rm -f "$tmpdepfile"
+  ;;
+
+aix)
+  # The C for AIX Compiler uses -M and outputs the dependencies
+  # in a .u file.  This file always lives in the current directory.
+  # Also, the AIX compiler puts `$object:' at the start of each line;
+  # $object doesn't have directory information.
+  stripped=`echo "$object" | sed -e 's,^.*/,,' -e 's/\(.*\)\..*$/\1/'`
+  tmpdepfile="$stripped.u"
+  outname="$stripped.o"
+  if test "$libtool" = yes; then
+    "$@" -Wc,-M
+  else
+    "$@" -M
+  fi
+
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+
+  if test -f "$tmpdepfile"; then
+    # Each line is of the form `foo.o: dependent.h'.
+    # Do two passes, one to just change these to
+    # `$object: dependent.h' and one to simply `dependent.h:'.
+    sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
+    sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
+  else
+    # The sourcefile does not contain any dependencies, so just
+    # store a dummy comment line, to avoid errors with the Makefile
+    # "include basename.Plo" scheme.
+    echo "#dummy" > "$depfile"
+  fi
+  rm -f "$tmpdepfile"
+  ;;
+
+tru64)
+   # The Tru64 compiler uses -MD to generate dependencies as a side
+   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
+   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
+   # dependencies in `foo.d' instead, so we check for that too.
+   # Subdirectories are respected.
+   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
+   test "x$dir" = "x$object" && dir=
+   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
+
+   if test "$libtool" = yes; then
+      tmpdepfile1="$dir.libs/$base.lo.d"
+      tmpdepfile2="$dir.libs/$base.d"
+      "$@" -Wc,-MD
+   else
+      tmpdepfile1="$dir$base.o.d"
+      tmpdepfile2="$dir$base.d"
+      "$@" -MD
+   fi
+
+   stat=$?
+   if test $stat -eq 0; then :
+   else
+      rm -f "$tmpdepfile1" "$tmpdepfile2"
+      exit $stat
+   fi
+
+   if test -f "$tmpdepfile1"; then
+      tmpdepfile="$tmpdepfile1"
+   else
+      tmpdepfile="$tmpdepfile2"
+   fi
+   if test -f "$tmpdepfile"; then
+      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
+      # That's a space and a tab in the [].
+      sed -e 's,^.*\.[a-z]*:[ 	]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
+   else
+      echo "#dummy" > "$depfile"
+   fi
+   rm -f "$tmpdepfile"
+   ;;
+
+#nosideeffect)
+  # This comment above is used by automake to tell side-effect
+  # dependency tracking mechanisms from slower ones.
+
+dashmstdout)
+  # Important note: in order to support this mode, a compiler *must*
+  # always write the proprocessed file to stdout, regardless of -o.
+  "$@" || exit $?
+
+  # Remove the call to Libtool.
+  if test "$libtool" = yes; then
+    while test $1 != '--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+
+  # Remove `-o $object'.  We will use -o /dev/null later,
+  # however we can't do the remplacement now because
+  # `-o $object' might simply not be used
+  IFS=" "
+  for arg
+  do
+    case $arg in
+    -o)
+      shift
+      ;;
+    $object)
+      shift
+      ;;
+    *)
+      set fnord "$@" "$arg"
+      shift # fnord
+      shift # $arg
+      ;;
+    esac
+  done
+
+  test -z "$dashmflag" && dashmflag=-M
+  "$@" -o /dev/null $dashmflag | sed 's:^[^:]*\:[ 	]*:'"$object"'\: :' > "$tmpdepfile"
+  rm -f "$depfile"
+  cat < "$tmpdepfile" > "$depfile"
+  tr ' ' '
+' < "$tmpdepfile" | \
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly.  Breaking it into two sed invocations is a workaround.
+    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+dashXmstdout)
+  # This case only exists to satisfy depend.m4.  It is never actually
+  # run, as this mode is specially recognized in the preamble.
+  exit 1
+  ;;
+
+makedepend)
+  "$@" || exit $?
+  # X makedepend
+  shift
+  cleared=no
+  for arg in "$@"; do
+    case $cleared in
+    no)
+      set ""; shift
+      cleared=yes ;;
+    esac
+    case "$arg" in
+    -D*|-I*)
+      set fnord "$@" "$arg"; shift ;;
+    -*)
+      ;;
+    *)
+      set fnord "$@" "$arg"; shift ;;
+    esac
+  done
+  obj_suffix="`echo $object | sed 's/^.*\././'`"
+  touch "$tmpdepfile"
+  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
+  rm -f "$depfile"
+  cat < "$tmpdepfile" > "$depfile"
+  sed '1,2d' "$tmpdepfile" | tr ' ' '
+' | \
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly.  Breaking it into two sed invocations is a workaround.
+    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile" "$tmpdepfile".bak
+  ;;
+
+cpp)
+  # Important note: in order to support this mode, a compiler *must*
+  # always write the proprocessed file to stdout.
+  "$@" || exit $?
+
+  # Remove the call to Libtool.
+  if test "$libtool" = yes; then
+    while test $1 != '--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+
+  # Remove `-o $object'.
+  IFS=" "
+  for arg
+  do
+    case $arg in
+    -o)
+      shift
+      ;;
+    $object)
+      shift
+      ;;
+    *)
+      set fnord "$@" "$arg"
+      shift # fnord
+      shift # $arg
+      ;;
+    esac
+  done
+
+  "$@" -E |
+    sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
+    sed '$ s: \\$::' > "$tmpdepfile"
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  cat < "$tmpdepfile" >> "$depfile"
+  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+msvisualcpp)
+  # Important note: in order to support this mode, a compiler *must*
+  # always write the proprocessed file to stdout, regardless of -o,
+  # because we must use -o when running libtool.
+  "$@" || exit $?
+  IFS=" "
+  for arg
+  do
+    case "$arg" in
+    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
+	set fnord "$@"
+	shift
+	shift
+	;;
+    *)
+	set fnord "$@" "$arg"
+	shift
+	shift
+	;;
+    esac
+  done
+  "$@" -E |
+  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
+  echo "	" >> "$depfile"
+  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+none)
+  exec "$@"
+  ;;
+
+*)
+  echo "Unknown depmode $depmode" 1>&2
+  exit 1
+  ;;
+esac
+
+exit 0


Property changes on: experimental/j/Elphel333/rtp/daemon/rtp/depcomp
___________________________________________________________________
Name: svn:executable
   + 

Added: experimental/j/Elphel333/rtp/daemon/rtp/drand48.c
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/drand48.c	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/drand48.c	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,13 @@
+#include "config_unix.h"
+#include "config_win32.h"
+#include "drand48.h"
+
+#ifdef NEED_DRAND48
+
+double drand48(void)
+{
+        unsigned int x = (rand() << 16) | rand();
+	return ((double)x / (double)0xffffffff);
+}
+
+#endif

Added: experimental/j/Elphel333/rtp/daemon/rtp/drand48.h
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/drand48.h	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/drand48.h	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,4 @@
+
+#ifdef NEED_DRAND48
+double drand48(void);
+#endif

Added: experimental/j/Elphel333/rtp/daemon/rtp/getaddrinfo.c
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/getaddrinfo.c	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/getaddrinfo.c	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,1114 @@
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * "#ifdef FAITH" part is local hack for supporting IPv4-v6 translator.
+ *
+ * Issues to be discussed:
+ * - Thread safe-ness must be checked.
+ * - Return values.  There are nonstandard return values defined and used
+ *   in the source code.  This is because RFC2553 is silent about which error
+ *   code must be returned for which situation.
+ * Note:
+ * - We use getipnodebyname() just for thread-safeness.  There's no intent
+ *   to let it do PF_UNSPEC (actually we never pass PF_UNSPEC to
+ *   getipnodebyname().
+ * - The code filters out AFs that are not supported by the kernel,
+ *   when globbing NULL hostname (to loopback, or wildcard).  Is it the right
+ *   thing to do?  What is the relationship with post-RFC2553 AI_ADDRCONFIG
+ *   in ai_flags?
+ */
+
+#ifndef lint
+static const char rcsid[] =
+     "@(#) $Header: /cvsroot/elphel/camera333/apps/streamers/landy/rtp/getaddrinfo.c,v 1.1.1.1 2005/03/18 09:18:08 elphel Exp $";
+#endif
+
+#include "config_unix.h"
+#include "config_win32.h"
+#include "debug.h"
+#include "memory.h"
+#include "inet_pton.h"
+#include "inet_ntop.h"
+#include <stddef.h>
+
+#ifndef HAVE_PORTABLE_PROTOTYPE
+#include "cdecl_ext.h"
+#endif 
+
+#ifndef HAVE_SOCKADDR_STORAGE
+#include "sockstorage.h"
+#endif 
+
+#ifdef NEED_ADDRINFO_H
+#include "addrinfo.h"
+#endif
+
+#ifdef NEED_IN6_IS_ADDR_V4MAPPED
+#define IN6_IS_ADDR_V4MAPPED(a) 	(((a)->s6_addr32[0] == 0) && \
+	 ((a)->s6_addr32[1] == 0) && \
+	 ((a)->s6_addr32[2] == htonl(0xffff0000)) && \
+	 ((a)->s6_addr32[3] != 0))
+#endif
+
+#ifdef NEED_IN_EXPERIMENTAL
+#define	IN_EXPERIMENTAL(i)	(((i) & 0xe0000000U) == 0xe0000000U)
+#endif
+
+#ifndef IN_LOOPBACKNET
+#define	IN_LOOPBACKNET		127			/* official! */
+#endif
+
+#if defined(__KAME__) && defined(INET6)
+# define FAITH
+#endif
+
+#define SUCCESS 0
+#define ANY 0
+#define YES 1
+#define NO  0
+
+#ifdef FAITH
+static int translate = NO;
+static struct in6_addr faith_prefix = IN6ADDR_ANY_INIT;
+#endif
+
+static const char in_addrany[] = { 0, 0, 0, 0 };
+static const char in6_addrany[] = {
+	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+static const char in_loopback[] = { 127, 0, 0, 1 }; 
+static const char in6_loopback[] = {
+	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
+};
+
+struct sockinet {
+	u_char	si_len;
+	u_char	si_family;
+	u_short	si_port;
+	uint32_t si_scope_id;
+};
+
+static const struct afd {
+	int a_af;
+	int a_addrlen;
+	int a_socklen;
+	int a_off;
+	const char *a_addrany;
+	const char *a_loopback;	
+	int a_scoped;
+} afdl [] = {
+#ifdef INET6
+	{PF_INET6, sizeof(struct in6_addr),
+	 sizeof(struct sockaddr_in6),
+	 offsetof(struct sockaddr_in6, sin6_addr),
+	 in6_addrany, in6_loopback, 1},
+#endif
+	{PF_INET, sizeof(struct in_addr),
+	 sizeof(struct sockaddr_in),
+	 offsetof(struct sockaddr_in, sin_addr),
+	 in_addrany, in_loopback, 0},
+	{0, 0, 0, 0, NULL, NULL, 0},
+};
+
+struct explore {
+	int e_af;
+	int e_socktype;
+	int e_protocol;
+	const char *e_protostr;
+	int e_wild;
+#define WILD_AF(ex)		((ex)->e_wild & 0x01)
+#define WILD_SOCKTYPE(ex)	((ex)->e_wild & 0x02)
+#define WILD_PROTOCOL(ex)	((ex)->e_wild & 0x04)
+};
+
+static const struct explore explore[] = {
+#if 0
+	{ PF_LOCAL, 0, ANY, ANY, NULL, 0x01 },
+#endif
+#ifdef INET6
+	{ PF_INET6, SOCK_DGRAM, IPPROTO_IPV6, "udp", 0x07 },
+	{ PF_INET6, SOCK_STREAM, IPPROTO_IPV6, "tcp", 0x07 },
+	{ PF_INET6, SOCK_RAW, ANY, NULL, 0x05 },
+#endif
+	{ PF_INET, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 },
+	{ PF_INET, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 },
+	{ PF_INET, SOCK_RAW, ANY, NULL, 0x05 },
+	{ -1, 0, 0, NULL, 0 },
+};
+
+#ifdef INET6
+#define PTON_MAX	16
+#else
+#define PTON_MAX	4
+#endif
+
+
+static int str_isnumber __P((const char *));
+static int explore_fqdn __P((const struct addrinfo *, const char *,
+	const char *, struct addrinfo **));
+static int explore_null __P((const struct addrinfo *, const char *,
+	const char *, struct addrinfo **));
+static int explore_numeric __P((const struct addrinfo *, const char *,
+	const char *, struct addrinfo **));
+static int explore_numeric_scope __P((const struct addrinfo *, const char *,
+	const char *, struct addrinfo **));
+static int get_name __P((const char *, const struct afd *, struct addrinfo **,
+	char *, const struct addrinfo *, const char *));
+static int get_canonname __P((const struct addrinfo *,
+	struct addrinfo *, const char *));
+static struct addrinfo *get_ai __P((const struct addrinfo *,
+	const struct afd *, const char *));
+static int get_portmatch __P((const struct addrinfo *, const char *));
+static int get_port __P((struct addrinfo *, const char *, int));
+static const struct afd *find_afd __P((int));
+
+static char *ai_errlist[] = {
+	"Success",
+	"Address family for hostname not supported",	/* EAI_ADDRFAMILY */
+	"Temporary failure in name resolution",		/* EAI_AGAIN      */
+	"Invalid value for ai_flags",		       	/* EAI_BADFLAGS   */
+	"Non-recoverable failure in name resolution", 	/* EAI_FAIL       */
+	"ai_family not supported",			/* EAI_FAMILY     */
+	"Memory allocation failure", 			/* EAI_MEMORY     */
+	"No address associated with hostname", 		/* EAI_NODATA     */
+	"hostname nor servname provided, or not known",	/* EAI_NONAME     */
+	"servname not supported for ai_socktype",	/* EAI_SERVICE    */
+	"ai_socktype not supported", 			/* EAI_SOCKTYPE   */
+	"System error returned in errno", 		/* EAI_SYSTEM     */
+	"Invalid value for hints",			/* EAI_BADHINTS	  */
+	"Resolved protocol is unknown",			/* EAI_PROTOCOL   */
+	"Unknown error", 				/* EAI_MAX        */
+};
+
+/* XXX macros that make external reference is BAD. */
+
+#define GET_AI(ai, afd, addr) \
+do { \
+	/* external reference: pai, error, and label free */ \
+	(ai) = get_ai(pai, (afd), (addr)); \
+	if ((ai) == NULL) { \
+		error = EAI_MEMORY; \
+		goto free; \
+	} \
+} while (0)
+
+#define GET_PORT(ai, serv) \
+do { \
+	/* external reference: error and label free */ \
+	error = get_port((ai), (serv), 0); \
+	if (error != 0) \
+		goto free; \
+} while (0)
+
+#define GET_CANONNAME(ai, str) \
+do { \
+	/* external reference: pai, error and label free */ \
+	error = get_canonname(pai, (ai), (str)); \
+	if (error != 0) \
+		goto free; \
+} while (0)
+
+#define ERR(err) \
+do { \
+	/* external reference: error, and label bad */ \
+	error = (err); \
+	goto bad; \
+} while (0)
+
+#define MATCH_FAMILY(x, y, w) \
+	((x) == (y) || ((w) && ((x) == PF_UNSPEC || (y) == PF_UNSPEC)))
+#define MATCH(x, y, w) \
+	((x) == (y) || ((w) && ((x) == ANY || (y) == ANY)))
+
+char *
+gai_strerror(ecode)
+	int ecode;
+{
+	if (ecode < 0 || ecode > EAI_MAX)
+		ecode = EAI_MAX;
+	return ai_errlist[ecode];
+}
+
+void
+freeaddrinfo(ai)
+	struct addrinfo *ai;
+{
+	struct addrinfo *next;
+
+	do {
+		next = ai->ai_next;
+		if (ai->ai_canonname)
+			free(ai->ai_canonname);
+		/* no need to free(ai->ai_addr) */
+		free(ai);
+	} while ((ai = next) != NULL);
+}
+
+static int
+str_isnumber(p)
+	const char *p;
+{
+	char *q = (char *)p;
+	while (*q) {
+		if (! isdigit(*q))
+			return NO;
+		q++;
+	}
+	return YES;
+}
+
+int
+getaddrinfo(hostname, servname, hints, res)
+	const char *hostname, *servname;
+	const struct addrinfo *hints;
+	struct addrinfo **res;
+{
+	struct addrinfo sentinel;
+	struct addrinfo *cur;
+	int error = 0;
+	struct addrinfo ai;
+	struct addrinfo ai0;
+	struct addrinfo *pai;
+	const struct afd *afd;
+	const struct explore *ex;
+
+#ifdef FAITH
+	static int firsttime = 1;
+
+	if (firsttime) {
+		/* translator hack */
+		char *q = getenv("GAI");
+		if (q && inet_pton(AF_INET6, q, &faith_prefix) == 1)
+			translate = YES;
+		firsttime = 0;
+	}
+#endif
+
+	sentinel.ai_next = NULL;
+	cur = &sentinel;
+	pai = &ai;
+	pai->ai_flags = 0;
+	pai->ai_family = PF_UNSPEC;
+	pai->ai_socktype = ANY;
+	pai->ai_protocol = ANY;
+	pai->ai_addrlen = 0;
+	pai->ai_canonname = NULL;
+	pai->ai_addr = NULL;
+	pai->ai_next = NULL;
+	
+	if (hostname == NULL && servname == NULL)
+		return EAI_NONAME;
+	if (hints) {
+		/* error check for hints */
+		if (hints->ai_addrlen || hints->ai_canonname ||
+		    hints->ai_addr || hints->ai_next)
+			ERR(EAI_BADHINTS); /* xxx */
+		if (hints->ai_flags & ~AI_MASK)
+			ERR(EAI_BADFLAGS);
+		switch (hints->ai_family) {
+		case PF_UNSPEC:
+		case PF_INET:
+#ifdef INET6
+		case PF_INET6:
+#endif
+			break;
+		default:
+			ERR(EAI_FAMILY);
+		}
+		memcpy(pai, hints, sizeof(*pai));
+
+		/*
+		 * if both socktype/protocol are specified, check if they
+		 * are meaningful combination.
+		 */
+		if (pai->ai_socktype != ANY && pai->ai_protocol != ANY) {
+			for (ex = explore; ex->e_af >= 0; ex++) {
+				if (pai->ai_family != ex->e_af)
+					continue;
+				if (ex->e_socktype == ANY)
+					continue;
+				if (ex->e_protocol == ANY)
+					continue;
+				if (pai->ai_socktype == ex->e_socktype
+				 && pai->ai_protocol != ex->e_protocol) {
+					ERR(EAI_BADHINTS);
+				}
+			}
+		}
+	}
+
+	/*
+	 * check for special cases.  (1) numeric servname is disallowed if
+	 * socktype/protocol are left unspecified. (2) servname is disallowed
+	 * for raw and other inet{,6} sockets.
+	 */
+	if (MATCH_FAMILY(pai->ai_family, PF_INET, 1)
+#ifdef PF_INET6
+	 || MATCH_FAMILY(pai->ai_family, PF_INET6, 1)
+#endif
+	    ) {
+		ai0 = *pai;
+
+		if (pai->ai_family == PF_UNSPEC) {
+#ifdef PF_INET6
+			pai->ai_family = PF_INET6;
+#else
+			pai->ai_family = PF_INET;
+#endif
+		}
+		error = get_portmatch(pai, servname);
+		if (error)
+			ERR(error);
+
+		*pai = ai0;
+	}
+
+	ai0 = *pai;
+
+	/* NULL hostname, or numeric hostname */
+	for (ex = explore; ex->e_af >= 0; ex++) {
+		*pai = ai0;
+
+		if (!MATCH_FAMILY(pai->ai_family, ex->e_af, WILD_AF(ex)))
+			continue;
+		if (!MATCH(pai->ai_socktype, ex->e_socktype, WILD_SOCKTYPE(ex)))
+			continue;
+		if (!MATCH(pai->ai_protocol, ex->e_protocol, WILD_PROTOCOL(ex)))
+			continue;
+
+		if (pai->ai_family == PF_UNSPEC)
+			pai->ai_family = ex->e_af;
+		if (pai->ai_socktype == ANY && ex->e_socktype != ANY)
+			pai->ai_socktype = ex->e_socktype;
+		if (pai->ai_protocol == ANY && ex->e_protocol != ANY)
+			pai->ai_protocol = ex->e_protocol;
+
+		if (hostname == NULL)
+			error = explore_null(pai, hostname, servname, &cur->ai_next);
+		else
+			error = explore_numeric_scope(pai, hostname, servname, &cur->ai_next);
+
+		if (error)
+			goto free;
+
+		while (cur && cur->ai_next)
+			cur = cur->ai_next;
+	}
+
+	/*
+	 * XXX
+	 * If numreic representation of AF1 can be interpreted as FQDN
+	 * representation of AF2, we need to think again about the code below.
+	 */
+	if (sentinel.ai_next)
+		goto good;
+
+	if (pai->ai_flags & AI_NUMERICHOST)
+		ERR(EAI_NONAME);
+	if (hostname == NULL)
+		ERR(EAI_NONAME);
+
+	/*
+	 * hostname as alphabetical name.
+	 * we would like to prefer AF_INET6 than AF_INET, so we'll make a
+	 * outer loop by AFs.
+	 */
+	for (afd = afdl; afd->a_af; afd++) {
+		*pai = ai0;
+
+		if (!MATCH_FAMILY(pai->ai_family, afd->a_af, 1))
+			continue;
+
+		for (ex = explore; ex->e_af >= 0; ex++) {
+			*pai = ai0;
+
+			if (pai->ai_family == PF_UNSPEC)
+				pai->ai_family = afd->a_af;
+
+			if (!MATCH_FAMILY(pai->ai_family, ex->e_af, WILD_AF(ex)))
+				continue;
+			if (!MATCH(pai->ai_socktype, ex->e_socktype,
+					WILD_SOCKTYPE(ex))) {
+				continue;
+			}
+			if (!MATCH(pai->ai_protocol, ex->e_protocol,
+					WILD_PROTOCOL(ex))) {
+				continue;
+			}
+
+			if (pai->ai_family == PF_UNSPEC)
+				pai->ai_family = ex->e_af;
+			if (pai->ai_socktype == ANY && ex->e_socktype != ANY)
+				pai->ai_socktype = ex->e_socktype;
+			if (pai->ai_protocol == ANY && ex->e_protocol != ANY)
+				pai->ai_protocol = ex->e_protocol;
+
+			error = explore_fqdn(pai, hostname, servname,
+				&cur->ai_next);
+
+			while (cur && cur->ai_next)
+				cur = cur->ai_next;
+		}
+	}
+
+	/* XXX */
+	if (sentinel.ai_next)
+		error = 0;
+
+	if (error)
+		goto free;
+	if (error == 0) {
+		if (sentinel.ai_next) {
+ good:
+			*res = sentinel.ai_next;
+			return SUCCESS;
+		} else
+			error = EAI_FAIL;
+	}
+ free:
+ bad:
+	if (sentinel.ai_next)
+		freeaddrinfo(sentinel.ai_next);
+	*res = NULL;
+	return error;
+}
+
+/*
+ * FQDN hostname, DNS lookup
+ */
+static int
+explore_fqdn(pai, hostname, servname, res)
+	const struct addrinfo *pai;
+	const char *hostname;
+	const char *servname;
+	struct addrinfo **res;
+{
+	struct hostent *hp;
+	int h_error;
+	int af;
+	char **aplist = NULL, *apbuf = NULL;
+	char *ap;
+	struct addrinfo sentinel, *cur;
+	int i;
+#ifndef USE_GETIPNODEBY
+	int naddrs;
+#endif
+	const struct afd *afd;
+	int error;
+
+	*res = NULL;
+	sentinel.ai_next = NULL;
+	cur = &sentinel;
+
+	/*
+	 * Do not filter unsupported AFs here.  We need to honor content of
+	 * databases (/etc/hosts, DNS and others).  Otherwise we cannot
+	 * replace gethostbyname() by getaddrinfo().
+	 */
+
+	/*
+	 * if the servname does not match socktype/protocol, ignore it.
+	 */
+	if (get_portmatch(pai, servname) != 0)
+		return 0;
+
+	afd = find_afd(pai->ai_family);
+
+	/*
+	 * post-RFC2553: should look at (pai->ai_flags & AI_ADDRCONFIG)
+	 * rather than hardcoding it.  we may need to add AI_ADDRCONFIG
+	 * handling code by ourselves in case we don't have getipnodebyname().
+	 */
+#ifdef USE_GETIPNODEBY
+	hp = getipnodebyname(hostname, pai->ai_family, AI_ADDRCONFIG, &h_error);
+#else
+#ifdef HAVE_GETHOSTBYNAME2
+	hp = gethostbyname2(hostname, pai->ai_family);
+#else
+	if (pai->ai_family != AF_INET)
+		return 0;
+	hp = gethostbyname(hostname);
+#ifdef HAVE_H_ERRNO
+	h_error = h_errno;
+#else
+	h_error = EINVAL;
+#endif
+#endif /*HAVE_GETHOSTBYNAME2*/
+#endif /*USE_GETIPNODEBY*/
+
+	if (hp == NULL) {
+		switch (h_error) {
+		case HOST_NOT_FOUND:
+		case NO_DATA:
+			error = EAI_NODATA;
+			break;
+		case TRY_AGAIN:
+			error = EAI_AGAIN;
+			break;
+		case NO_RECOVERY:
+		case NETDB_INTERNAL:
+		default:
+			error = EAI_FAIL;
+			break;
+		}
+	} else if ((hp->h_name == NULL) || (hp->h_name[0] == 0)
+			|| (hp->h_addr_list[0] == NULL)) {
+#ifdef USE_GETIPNODEBY
+		freehostent(hp);
+#endif
+		hp = NULL;
+		error = EAI_FAIL;
+	}
+
+	if (hp == NULL)
+		goto free;
+
+#ifdef USE_GETIPNODEBY
+	aplist = hp->h_addr_list;
+#else
+	/*
+	 * hp will be overwritten if we use gethostbyname2().
+	 * always deep copy for simplification.
+	 */
+	for (naddrs = 0; hp->h_addr_list[naddrs] != NULL; naddrs++)
+		;
+	naddrs++;
+	aplist = (char **)malloc(sizeof(aplist[0]) * naddrs);
+	apbuf = (char *)malloc(hp->h_length * naddrs);
+	if (aplist == NULL || apbuf == NULL) {
+		error = EAI_MEMORY;
+		goto free;
+	}
+	memset(aplist, 0, sizeof(aplist[0]) * naddrs);
+	for (i = 0; i < naddrs; i++) {
+		if (hp->h_addr_list[i] == NULL) {
+			aplist[i] = NULL;
+			continue;
+		}
+		memcpy(&apbuf[i * hp->h_length], hp->h_addr_list[i],
+			hp->h_length);
+		aplist[i] = &apbuf[i * hp->h_length];
+	}
+#endif
+
+	for (i = 0; aplist[i] != NULL; i++) {
+		af = hp->h_addrtype;
+		ap = aplist[i];
+#ifdef AF_INET6
+		if (af == AF_INET6
+		 && IN6_IS_ADDR_V4MAPPED((struct in6_addr *)ap)) {
+			af = AF_INET;
+			ap = ap + sizeof(struct in6_addr)
+				- sizeof(struct in_addr);
+		}
+#endif
+
+		if (af != pai->ai_family)
+			continue;
+
+		if ((pai->ai_flags & AI_CANONNAME) == 0) {
+			GET_AI(cur->ai_next, afd, ap);
+			GET_PORT(cur->ai_next, servname);
+		} else {
+			/*
+			 * if AI_CANONNAME and if reverse lookup
+			 * fail, return ai anyway to pacify
+			 * calling application.
+			 *
+			 * XXX getaddrinfo() is a name->address
+			 * translation function, and it looks
+			 * strange that we do addr->name
+			 * translation here.
+			 */
+			get_name(ap, afd, &cur->ai_next,
+				ap, pai, servname);
+		}
+
+		while (cur && cur->ai_next)
+			cur = cur->ai_next;
+	}
+
+	*res = sentinel.ai_next;
+	return 0;
+
+free:
+#ifdef USE_GETIPNODEBY
+	if (hp)
+		freehostent(hp);
+#endif
+	if (aplist)
+		free(aplist);
+	if (apbuf)
+		free(apbuf);
+	if (sentinel.ai_next)
+		freeaddrinfo(sentinel.ai_next);
+	return error;
+}
+
+/*
+ * hostname == NULL.
+ * passive socket -> anyaddr (0.0.0.0 or ::)
+ * non-passive socket -> localhost (127.0.0.1 or ::1)
+ */
+static int
+explore_null(pai, hostname, servname, res)
+	const struct addrinfo *pai;
+	const char *hostname;
+	const char *servname;
+	struct addrinfo **res;
+{
+	int s;
+	const struct afd *afd;
+	struct addrinfo *cur;
+	struct addrinfo sentinel;
+	int error;
+
+	*res = NULL;
+	sentinel.ai_next = NULL;
+	cur = &sentinel;
+
+	/*
+	 * filter out AFs that are not supported by the kernel
+	 * XXX errno?
+	 */
+	s = socket(pai->ai_family, SOCK_DGRAM, 0);
+	if (s < 0) {
+		if (errno != EMFILE)
+			return 0;
+	} else
+		close(s);
+
+	/*
+	 * if the servname does not match socktype/protocol, ignore it.
+	 */
+	if (get_portmatch(pai, servname) != 0)
+		return 0;
+
+	afd = find_afd(pai->ai_family);
+
+	if (pai->ai_flags & AI_PASSIVE) {
+		GET_AI(cur->ai_next, afd, afd->a_addrany);
+		/* xxx meaningless?
+		 * GET_CANONNAME(cur->ai_next, "anyaddr");
+		 */
+		GET_PORT(cur->ai_next, servname);
+	} else {
+		GET_AI(cur->ai_next, afd, afd->a_loopback);
+		/* xxx meaningless?
+		 * GET_CANONNAME(cur->ai_next, "localhost");
+		 */
+		GET_PORT(cur->ai_next, servname);
+	}
+	cur = cur->ai_next;
+
+	*res = sentinel.ai_next;
+	return 0;
+
+free:
+	if (sentinel.ai_next)
+		freeaddrinfo(sentinel.ai_next);
+	return error;
+}
+
+/*
+ * numeric hostname
+ */
+static int
+explore_numeric(pai, hostname, servname, res)
+	const struct addrinfo *pai;
+	const char *hostname;
+	const char *servname;
+	struct addrinfo **res;
+{
+	const struct afd *afd;
+	struct addrinfo *cur;
+	struct addrinfo sentinel;
+	int error;
+	char pton[PTON_MAX];
+	int flags;
+
+	*res = NULL;
+	sentinel.ai_next = NULL;
+	cur = &sentinel;
+
+	/*
+	 * if the servname does not match socktype/protocol, ignore it.
+	 */
+	if (get_portmatch(pai, servname) != 0)
+		return 0;
+
+	afd = find_afd(pai->ai_family);
+	flags = pai->ai_flags;
+
+	if (inet_pton(afd->a_af, hostname, pton) == 1) {
+		uint32_t v4a;
+#ifdef INET6
+		u_char pfx;
+#endif
+
+		switch (afd->a_af) {
+		case AF_INET:
+			v4a = (uint32_t)ntohl(((struct in_addr *)pton)->s_addr);
+			if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a))
+				flags &= ~AI_CANONNAME;
+			v4a >>= IN_CLASSA_NSHIFT;
+			if (v4a == 0 || v4a == IN_LOOPBACKNET)
+				flags &= ~AI_CANONNAME;
+			break;
+#ifdef INET6
+		case AF_INET6:
+			pfx = ((struct in6_addr *)pton)->s6_addr[0];
+			if (pfx == 0 || pfx == 0xfe || pfx == 0xff)
+				flags &= ~AI_CANONNAME;
+			break;
+#endif
+		}
+
+		if (pai->ai_family == afd->a_af ||
+		    pai->ai_family == PF_UNSPEC /*?*/) {
+			if ((flags & AI_CANONNAME) == 0) {
+				GET_AI(cur->ai_next, afd, pton);
+				GET_PORT(cur->ai_next, servname);
+			} else {
+				/*
+				 * if AI_CANONNAME and if reverse lookup
+				 * fail, return ai anyway to pacify
+				 * calling application.
+				 *
+				 * XXX getaddrinfo() is a name->address
+				 * translation function, and it looks
+				 * strange that we do addr->name
+				 * translation here.
+				 */
+				get_name(pton, afd, &cur->ai_next,
+					pton, pai, servname);
+			}
+			while (cur && cur->ai_next)
+				cur = cur->ai_next;
+		} else 
+			ERR(EAI_FAMILY);	/*xxx*/
+	}
+
+	*res = sentinel.ai_next;
+	return 0;
+
+free:
+bad:
+	if (sentinel.ai_next)
+		freeaddrinfo(sentinel.ai_next);
+	return error;
+}
+
+/*
+ * numeric hostname with scope
+ */
+static int
+explore_numeric_scope(pai, hostname, servname, res)
+	const struct addrinfo *pai;
+	const char *hostname;
+	const char *servname;
+	struct addrinfo **res;
+{
+#ifndef SCOPE_DELIMITER
+	return explore_numeric(pai, hostname, servname, res);
+#else
+	const struct afd *afd;
+	struct addrinfo *cur;
+	int error;
+	char *cp, *hostname2 = NULL;
+	int scope;
+	struct sockaddr_in6 *sin6;
+
+	/*
+	 * if the servname does not match socktype/protocol, ignore it.
+	 */
+	if (get_portmatch(pai, servname) != 0)
+		return 0;
+
+	afd = find_afd(pai->ai_family);
+	if (!afd->a_scoped)
+		return explore_numeric(pai, hostname, servname, res);
+
+	cp = strchr(hostname, SCOPE_DELIMITER);
+	if (cp == NULL)
+		return explore_numeric(pai, hostname, servname, res);
+
+	/*
+	 * Handle special case of <scoped_address><delimiter><scope id>
+	 */
+	hostname2 = strdup(hostname);
+	if (hostname2 == NULL)
+		return EAI_MEMORY;
+	/* terminate at the delimiter */
+	hostname2[cp - hostname] = '\0';
+
+	cp++;
+	switch (pai->ai_family) {
+#ifdef INET6
+	case AF_INET6:
+		scope = if_nametoindex(cp);
+		if (scope == 0) {
+			free(hostname2);
+			return (EAI_NONAME);
+		}
+		break;
+#endif
+	}
+
+	error = explore_numeric(pai, hostname2, servname, res);
+	if (error == 0) {
+		for (cur = *res; cur; cur = cur->ai_next) {
+			if (cur->ai_family != AF_INET6)
+				continue;
+			sin6 = (struct sockaddr_in6 *)cur->ai_addr;
+			if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr) ||
+			    IN6_IS_ADDR_MC_LINKLOCAL(&sin6->sin6_addr))
+				sin6->sin6_scope_id = scope;
+		}
+	}
+
+	free(hostname2);
+
+	return error;
+#endif
+}
+
+static int
+get_name(addr, afd, res, numaddr, pai, servname)
+	const char *addr;
+	const struct afd *afd;
+	struct addrinfo **res;
+	char *numaddr;
+	const struct addrinfo *pai;
+	const char *servname;
+{
+	struct hostent *hp = NULL;
+	struct addrinfo *cur = NULL;
+	int error = 0;
+	char *ap = NULL, *cn = NULL;
+#ifdef USE_GETIPNODEBY
+	int h_error;
+
+	hp = getipnodebyaddr(addr, afd->a_addrlen, afd->a_af, &h_error);
+#else
+	hp = gethostbyaddr(addr, afd->a_addrlen, afd->a_af);
+#endif
+	if (hp && hp->h_name && hp->h_name[0] && hp->h_addr_list[0]) {
+#ifdef USE_GETIPNODEBY
+		GET_AI(cur, afd, hp->h_addr_list[0]);
+		GET_PORT(cur, servname);
+		GET_CANONNAME(cur, hp->h_name);
+#else
+		/* hp will be damaged if we use gethostbyaddr() */
+		if ((ap = (char *)malloc(hp->h_length)) == NULL) {
+			error = EAI_MEMORY;
+			goto free;
+		}
+		memcpy(ap, hp->h_addr_list[0], hp->h_length);
+		if ((cn = strdup(hp->h_name)) == NULL) {
+			error = EAI_MEMORY;
+			goto free;
+		}
+
+		GET_AI(cur, afd, ap);
+		GET_PORT(cur, servname);
+		GET_CANONNAME(cur, cn);
+		free(ap); ap = NULL;
+		free(cn); cn = NULL;
+#endif
+	} else {
+		GET_AI(cur, afd, numaddr);
+		GET_PORT(cur, servname);
+	}
+	
+#ifdef USE_GETIPNODEBY
+	if (hp)
+		freehostent(hp);
+#endif
+	*res = cur;
+	return SUCCESS;
+ free:
+	if (cur)
+		freeaddrinfo(cur);
+	if (ap)
+		free(ap);
+	if (cn)
+		free(cn);
+#ifdef USE_GETIPNODEBY
+	if (hp)
+		freehostent(hp);
+#endif
+	*res = NULL;
+	return error;
+}
+
+static int
+get_canonname(pai, ai, str)
+	const struct addrinfo *pai;
+	struct addrinfo *ai;
+	const char *str;
+{
+	if ((pai->ai_flags & AI_CANONNAME) != 0) {
+		ai->ai_canonname = (char *)malloc(strlen(str) + 1);
+		if (ai->ai_canonname == NULL)
+			return EAI_MEMORY;
+		strcpy(ai->ai_canonname, str);
+	}
+	return 0;
+}
+
+static struct addrinfo *
+get_ai(pai, afd, addr)
+	const struct addrinfo *pai;
+	const struct afd *afd;
+	const char *addr;
+{
+	char *p;
+	struct addrinfo *ai;
+
+	ai = (struct addrinfo *)malloc(sizeof(struct addrinfo)
+		+ (afd->a_socklen));
+	if (ai == NULL)
+		return NULL;
+
+	memcpy(ai, pai, sizeof(struct addrinfo));
+	ai->ai_addr = (struct sockaddr *)(ai + 1);
+	memset(ai->ai_addr, 0, afd->a_socklen);
+#ifdef HAVE_SOCKADDR_SA_LEN
+	ai->ai_addr->sa_len = afd->a_socklen;
+#endif
+	ai->ai_addrlen = afd->a_socklen;
+	ai->ai_addr->sa_family = ai->ai_family = afd->a_af;
+	p = (char *)(ai->ai_addr);
+	memcpy(p + afd->a_off, addr, afd->a_addrlen);
+	return ai;
+}
+
+static int
+get_portmatch(ai, servname)
+	const struct addrinfo *ai;
+	const char *servname;
+{
+
+	/* get_port does not touch first argument. when matchonly == 1. */
+	return get_port((struct addrinfo *)ai, servname, 1);
+}
+
+static int
+get_port(ai, servname, matchonly)
+	struct addrinfo *ai;
+	const char *servname;
+	int matchonly;
+{
+	const char *proto;
+	struct servent *sp;
+	int port;
+	int allownumeric;
+
+	if (servname == NULL)
+		return 0;
+	switch (ai->ai_family) {
+	case AF_INET:
+#ifdef AF_INET6
+	case AF_INET6:
+#endif
+		break;
+	default:
+		return 0;
+	}
+
+	switch (ai->ai_socktype) {
+	case SOCK_RAW:
+		return EAI_SERVICE;
+	case SOCK_DGRAM:
+	case SOCK_STREAM:
+		allownumeric = 1;
+		break;
+	case ANY:
+		allownumeric = 0;
+		break;
+	default:
+		return EAI_SOCKTYPE;
+	}
+
+	if (str_isnumber(servname)) {
+		if (!allownumeric)
+			return EAI_SERVICE;
+		port = htons(atoi(servname));
+		if (port < 0 || port > 65535)
+			return EAI_SERVICE;
+	} else {
+		switch (ai->ai_socktype) {
+		case SOCK_DGRAM:
+			proto = "udp";
+			break;
+		case SOCK_STREAM:
+			proto = "tcp";
+			break;
+		default:
+			proto = NULL;
+			break;
+		}
+
+		if ((sp = getservbyname(servname, proto)) == NULL)
+			return EAI_SERVICE;
+		port = sp->s_port;
+	}
+
+	if (!matchonly) {
+		switch (ai->ai_family) {
+		case AF_INET:
+			((struct sockaddr_in *)ai->ai_addr)->sin_port = port;
+			break;
+#ifdef INET6
+		case AF_INET6:
+			((struct sockaddr_in6 *)ai->ai_addr)->sin6_port = port;
+			break;
+#endif
+		}
+	}
+
+	return 0;
+}
+
+static const struct afd *
+find_afd(af)
+	int af;
+{
+	const struct afd *afd;
+
+	if (af == PF_UNSPEC)
+		return NULL;
+	for (afd = afdl; afd->a_af; afd++) {
+		if (afd->a_af == af)
+			return afd;
+	}
+	return NULL;
+}

Added: experimental/j/Elphel333/rtp/daemon/rtp/gettimeofday.c
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/gettimeofday.c	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/gettimeofday.c	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,17 @@
+#include "config_unix.h"
+#include "config_win32.h"
+#include "gettimeofday.h"
+
+#if defined(NEED_GETTIMEOFDAY) && defined(WIN32)
+
+int gettimeofday(struct timeval *tp, void *tz)
+{
+	struct _timeb timebuffer;   
+
+	_ftime( &timebuffer );
+	tp->tv_sec  = timebuffer.time;
+	tp->tv_usec = timebuffer.millitm * 1000;
+	return 0;
+}
+
+#endif

Added: experimental/j/Elphel333/rtp/daemon/rtp/gettimeofday.h
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/gettimeofday.h	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/gettimeofday.h	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,6 @@
+#if defined(NEED_GETTIMEOFDAY) || defined(_WIN32)
+
+int gettimeofday(struct timeval *tp, void *);
+
+#endif
+

Added: experimental/j/Elphel333/rtp/daemon/rtp/hmac.c
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/hmac.c	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/hmac.c	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,158 @@
+/*
+ * FILE:    hmac.c
+ * AUTHORS: Colin Perkins
+ *
+ * HMAC message authentication (RFC2104)
+ * 
+ * Copyright (c) 1998-2000 University College London
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, is permitted provided that the following conditions 
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by the Computer Science
+ *      Department at University College London
+ * 4. Neither the name of the University nor of the Department may be used
+ *    to endorse or promote products derived from this software without
+ *    specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "config_unix.h"
+#include "config_win32.h"
+#include "md5.h"
+#include "hmac.h"
+
+/**
+ * hmac_md5:
+ * @data: pointer to data stream.
+ * @data_len: length of data stream in bytes.
+ * @key: pointer to authentication key.
+ * @key_len: length of authentication key in bytes.
+ * @digest: digest to be filled in.
+ * 
+ * Computes MD5 @digest of @data using key @key. 
+ * 
+ **/
+void hmac_md5(unsigned char   *data,	   
+	      int              data_len,   
+	      unsigned char   *key, 	   
+	      int              key_len,	   
+	      unsigned char    digest[16]) 
+{
+        MD5_CTX       context;
+        unsigned char k_ipad[65];    /* inner padding - key XORd with ipad */
+        unsigned char k_opad[65];    /* outer padding - key XORd with opad */
+        unsigned char tk[16];
+        int           i;
+
+        /* If key is longer than 64 bytes reset it to key=MD5(key) */
+        if (key_len > 64) {
+                MD5_CTX      tctx;
+
+                MD5Init(&tctx);
+                MD5Update(&tctx, key, key_len);
+                MD5Final(tk, &tctx);
+
+                key     = tk;
+                key_len = 16;
+        }
+
+        /*
+         * The HMAC_MD5 transform looks like:
+         *
+         * MD5(K XOR opad, MD5(K XOR ipad, data))
+         *
+         * where K is an n byte key
+         * ipad is the byte 0x36 repeated 64 times
+         * opad is the byte 0x5c repeated 64 times
+         * and text is the data being protected
+         */
+
+        /* Start out by storing key in pads */
+        memset(k_ipad, 0, sizeof(k_ipad));
+        memset(k_opad, 0, sizeof(k_opad));
+        memcpy(k_ipad, key, key_len);
+        memcpy(k_opad, key, key_len);
+
+        /* XOR key with ipad and opad values */
+        for (i=0; i<64; i++) {
+                k_ipad[i] ^= 0x36;
+                k_opad[i] ^= 0x5c;
+        }
+        /*
+         * perform inner MD5
+         */
+        MD5Init(&context);                   /* init context for 1st pass */
+        MD5Update(&context, k_ipad, 64);     /* start with inner pad      */
+        MD5Update(&context, data, data_len); /* then text of datagram     */
+        MD5Final(digest, &context);          /* finish up 1st pass        */
+        /*
+         * perform outer MD5
+         */
+        MD5Init(&context);                   /* init context for 2nd pass */
+        MD5Update(&context, k_opad, 64);     /* start with outer pad      */
+        MD5Update(&context, digest, 16);     /* then results of 1st hash  */
+        MD5Final(digest, &context);          /* finish up 2nd pass        */
+}
+
+/*
+ * Test Vectors (Trailing '\0' of a character string not included in test):
+ * 
+ * key =         0x0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b
+ * key_len =     16 bytes
+ * data =        "Hi There"
+ * data_len =    8  bytes
+ * digest =      0x9294727a3638bb1c13f48ef8158bfc9d
+ *
+ * key =         "Jefe"
+ * data =        "what do ya want for nothing?"
+ * data_len =    28 bytes
+ * digest =      0x750c783e6ab0b503eaa86e310a5db738
+ *
+ * key =         0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ * key_len       16 bytes
+ * data =        0xDDDDDDDDDDDDDDDDDDDD...
+ *               ..DDDDDDDDDDDDDDDDDDDD...
+ *               ..DDDDDDDDDDDDDDDDDDDD...
+ *               ..DDDDDDDDDDDDDDDDDDDD...
+ *               ..DDDDDDDDDDDDDDDDDDDD
+ * data_len =    50 bytes
+ * digest =      0x56be34521d144c88dbb8c733f0e8b3f6
+ */
+
+#ifdef TEST_HMAC
+int main()
+{
+	unsigned char	*key  = "Jefe";
+	unsigned char	*data = "what do ya want for nothing?";
+	unsigned char	 digest[16];
+	int		 i;
+
+	hmac_md5(data, 28, key, 4, digest);
+	for (i = 0; i < 16; i++) {
+		printf("%02x", digest[i]);
+	}
+	printf("\n");
+
+	return 0;
+}
+#endif
+

Added: experimental/j/Elphel333/rtp/daemon/rtp/hmac.h
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/hmac.h	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/hmac.h	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,41 @@
+/*
+ * FILE:    hmac.h
+ * AUTHORS: Colin Perkins
+ *
+ * HMAC message authentication (RFC2104)
+ * 
+ * Copyright (c) 1998-2000 University College London
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, is permitted provided that the following conditions 
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by the Computer Science
+ *      Department at University College London
+ * 4. Neither the name of the University nor of the Department may be used
+ *    to endorse or promote products derived from this software without
+ *    specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+void hmac_md5(unsigned char *data, int data_len, 
+              unsigned char *key,  int key_len,
+	      unsigned char  digest[16]);
+

Added: experimental/j/Elphel333/rtp/daemon/rtp/inet_ntop.c
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/inet_ntop.c	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/inet_ntop.c	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,195 @@
+/* This is from the BIND 4.9.4 release, modified to compile by itself */
+
+/* Copyright (c) 1996 by Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+#ifndef _WIN32
+#include "uclconf.h"
+#endif
+#ifndef HAVE_INET_NTOP
+#include "config_unix.h"
+#include "config_win32.h"
+#include "inet_ntop.h"
+
+#define	IN6ADDRSZ	16
+#define	INT16SZ		 2
+
+#ifndef	AF_INET6
+#define	AF_INET6	AF_MAX+1	/* just to let this compile */
+#endif
+
+/*
+ * WARNING: Don't even consider trying to compile this on a system where
+ * sizeof(int) < 4.  sizeof(int) > 4 is fine; all the world's not a VAX.
+ */
+
+static const char *inet_ntop4(const u_char *src, char *dst, size_t size);
+static const char *inet_ntop6(const u_char *src, char *dst, size_t size);
+
+/* char *
+ * inet_ntop(af, src, dst, size)
+ *	convert a network format address to presentation format.
+ * return:
+ *	pointer to presentation format address (`dst'), or NULL (see errno).
+ * author:
+ *	Paul Vixie, 1996.
+ */
+const char *
+inet_ntop(af, src, dst, size)
+	int af;
+	const void *src;
+	char *dst;
+	size_t size;
+{
+	switch (af) {
+	case AF_INET:
+		return (inet_ntop4(src, dst, size));
+	case AF_INET6:
+		return (inet_ntop6(src, dst, size));
+	default:
+		errno = EAFNOSUPPORT;
+		return (NULL);
+	}
+	/* NOTREACHED */
+}
+
+/* const char *
+ * inet_ntop4(src, dst, size)
+ *	format an IPv4 address, more or less like inet_ntoa()
+ * return:
+ *	`dst' (as a const)
+ * notes:
+ *	(1) uses no statics
+ *	(2) takes a u_char* not an in_addr as input
+ * author:
+ *	Paul Vixie, 1996.
+ */
+static const char *
+inet_ntop4(src, dst, size)
+	const u_char *src;
+	char *dst;
+	size_t size;
+{
+	static const char fmt[] = "%u.%u.%u.%u";
+	char tmp[sizeof "255.255.255.255"];
+
+	sprintf(tmp, fmt, src[0], src[1], src[2], src[3]);
+	if ((size_t)strlen(tmp) > size) {
+		errno = ENOSPC;
+		return (NULL);
+	}
+	strcpy(dst, tmp);
+	return (dst);
+}
+
+/* const char *
+ * inet_ntop6(src, dst, size)
+ *	convert IPv6 binary address into presentation (printable) format
+ * author:
+ *	Paul Vixie, 1996.
+ */
+static const char *
+inet_ntop6(src, dst, size)
+	const u_char *src;
+	char *dst;
+	size_t size;
+{
+	/*
+	 * Note that int32_t and int16_t need only be "at least" large enough
+	 * to contain a value of the specified size.  On some systems, like
+	 * Crays, there is no such thing as an integer variable with 16 bits.
+	 * Keep this in mind if you think this function should have been coded
+	 * to use pointer overlays.  All the world's not a VAX.
+	 */
+	char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp;
+	struct { int base, len; } best, cur;
+	uint32_t words[IN6ADDRSZ / INT16SZ];
+	int i;
+
+	/*
+	 * Preprocess:
+	 *	Copy the input (bytewise) array into a wordwise array.
+	 *	Find the longest run of 0x00's in src[] for :: shorthanding.
+	 */
+	memset(words, 0, sizeof words);
+	for (i = 0; i < IN6ADDRSZ; i++)
+		words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3));
+	best.base = -1;
+	cur.base = -1;
+	for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) {
+		if (words[i] == 0) {
+			if (cur.base == -1)
+				cur.base = i, cur.len = 1;
+			else
+				cur.len++;
+		} else {
+			if (cur.base != -1) {
+				if (best.base == -1 || cur.len > best.len)
+					best = cur;
+				cur.base = -1;
+			}
+		}
+	}
+	if (cur.base != -1) {
+		if (best.base == -1 || cur.len > best.len)
+			best = cur;
+	}
+	if (best.base != -1 && best.len < 2)
+		best.base = -1;
+
+	/*
+	 * Format the result.
+	 */
+	tp = tmp;
+	for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) {
+		/* Are we inside the best run of 0x00's? */
+		if (best.base != -1 && i >= best.base &&
+		    i < (best.base + best.len)) {
+			if (i == best.base)
+				*tp++ = ':';
+			continue;
+		}
+		/* Are we following an initial run of 0x00s or any real hex? */
+		if (i != 0)
+			*tp++ = ':';
+		/* Is this address an encapsulated IPv4? */
+		if (i == 6 && best.base == 0 &&
+		    (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) {
+			if (!inet_ntop4(src+12, tp, sizeof tmp - (tp - tmp)))
+				return (NULL);
+			tp += strlen(tp);
+			break;
+		}
+		sprintf(tp, "%x", words[i]);
+		tp += strlen(tp);
+	}
+	/* Was it a trailing run of 0x00's? */
+	if (best.base != -1 && (best.base + best.len) == (IN6ADDRSZ / INT16SZ))
+		*tp++ = ':';
+	*tp++ = '\0';
+
+	/*
+	 * Check for overflow, copy, and we're done.
+	 */
+	if ((size_t) (tp - tmp) > size) {
+		errno = ENOSPC;
+		return (NULL);
+	}
+	strcpy(dst, tmp);
+	return (dst);
+}
+
+#endif
+

Added: experimental/j/Elphel333/rtp/daemon/rtp/inet_ntop.h
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/inet_ntop.h	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/inet_ntop.h	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,11 @@
+#ifndef HAVE_INET_NTOP
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+const char *inet_ntop(int af, const void *src, char *dst, size_t size);
+
+#if defined(__cplusplus)
+}
+#endif
+#endif /* HAVE_INET_NTOP */

Added: experimental/j/Elphel333/rtp/daemon/rtp/inet_pton.c
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/inet_pton.c	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/inet_pton.c	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,221 @@
+/* This is from the BIND 4.9.4 release, modified to compile by itself */
+
+/* Copyright (c) 1996 by Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+#include "config_unix.h"
+#ifndef HAVE_INET_PTON
+#include "config_win32.h"
+#include "inet_pton.h"
+
+#define	IN6ADDRSZ	16
+#define	INADDRSZ	 4
+#define	INT16SZ		 2
+
+#ifndef	AF_INET6
+#define	AF_INET6	AF_MAX+1	/* just to let this compile */
+#endif
+
+/*
+ * WARNING: Don't even consider trying to compile this on a system where
+ * sizeof(int) < 4.  sizeof(int) > 4 is fine; all the world's not a VAX.
+ */
+
+static int	inet_pton4(const char *src, u_char *dst);
+static int	inet_pton6(const char *src, u_char *dst);
+
+/* int
+ * inet_pton(af, src, dst)
+ *	convert from presentation format (which usually means ASCII printable)
+ *	to network format (which is usually some kind of binary format).
+ * return:
+ *	1 if the address was valid for the specified address family
+ *	0 if the address wasn't valid (`dst' is untouched in this case)
+ *	-1 if some other error occurred (`dst' is untouched in this case, too)
+ * author:
+ *	Paul Vixie, 1996.
+ */
+int
+inet_pton(af, src, dst)
+	int af;
+	const char *src;
+	void *dst;
+{
+	switch (af) {
+	case AF_INET:
+		return (inet_pton4(src, dst));
+	case AF_INET6:
+		return (inet_pton6(src, dst));
+	default:
+		errno = EAFNOSUPPORT;
+		return (-1);
+	}
+	/* NOTREACHED */
+}
+
+/* int
+ * inet_pton4(src, dst)
+ *	like inet_aton() but without all the hexadecimal and shorthand.
+ * return:
+ *	1 if `src' is a valid dotted quad, else 0.
+ * notice:
+ *	does not touch `dst' unless it's returning 1.
+ * author:
+ *	Paul Vixie, 1996.
+ */
+static int
+inet_pton4(src, dst)
+	const char *src;
+	u_char *dst;
+{
+	static const char digits[] = "0123456789";
+	int saw_digit, octets, ch;
+	u_char tmp[INADDRSZ], *tp;
+
+	saw_digit = 0;
+	octets = 0;
+	*(tp = tmp) = 0;
+	while ((ch = *src++) != '\0') {
+		const char *pch;
+
+		if ((pch = (char *) strchr(digits, ch)) != NULL) {
+		  unsigned int temp = *tp * 10 + (pch - digits);
+uint8_t newv;
+			if (temp > 255)
+				return (0);
+			newv = (uint8_t) temp;
+			*tp = newv;
+			if (! saw_digit) {
+				if (++octets > 4)
+					return (0);
+				saw_digit = 1;
+			}
+		} else if (ch == '.' && saw_digit) {
+			if (octets == 4)
+				return (0);
+			*++tp = 0;
+			saw_digit = 0;
+		} else
+			return (0);
+	}
+	if (octets < 4)
+		return (0);
+	/* bcopy(tmp, dst, INADDRSZ); */
+	memcpy(dst, tmp, INADDRSZ);
+	return (1);
+}
+
+/* int
+ * inet_pton6(src, dst)
+ *	convert presentation level address to network order binary form.
+ * return:
+ *	1 if `src' is a valid [RFC1884 2.2] address, else 0.
+ * notice:
+ *	(1) does not touch `dst' unless it's returning 1.
+ *	(2) :: in a full address is silently ignored.
+ * credit:
+ *	inspired by Mark Andrews.
+ * author:
+ *	Paul Vixie, 1996.
+ */
+static int
+inet_pton6(src, dst)
+	const char *src;
+	u_char *dst;
+{
+	static const char xdigits_l[] = "0123456789abcdef",
+			  xdigits_u[] = "0123456789ABCDEF";
+	u_char tmp[IN6ADDRSZ], *tp, *endp, *colonp;
+	const char *xdigits, *curtok;
+	int ch, saw_xdigit;
+	unsigned val;
+
+	memset((tp = tmp), 0, IN6ADDRSZ);
+	endp = tp + IN6ADDRSZ;
+	colonp = NULL;
+	/* Leading :: requires some special handling. */
+	if (*src == ':')
+		if (*++src != ':')
+			return (0);
+	curtok = src;
+	saw_xdigit = 0;
+	val = 0;
+	while ((ch = *src++) != '\0') {
+		const char *pch;
+
+		if ((pch = (char *) strchr((xdigits = xdigits_l), ch)) == NULL)
+			pch = (char *) strchr((xdigits = xdigits_u), ch);
+		if (pch != NULL) {
+			val <<= 4;
+			val |= (pch - xdigits);
+			if (val > 0xffff)
+				return (0);
+			saw_xdigit = 1;
+			continue;
+		}
+		if (ch == ':') {
+			curtok = src;
+			if (!saw_xdigit) {
+				if (colonp)
+					return (0);
+				colonp = tp;
+				continue;
+			}
+			if (tp + INT16SZ > endp)
+				return (0);
+			*tp++ = (u_char) (val >> 8) & 0xff;
+			*tp++ = (u_char) val & 0xff;
+			saw_xdigit = 0;
+			val = 0;
+			continue;
+		}
+		if (ch == '.' && ((tp + INADDRSZ) <= endp) &&
+		    inet_pton4(curtok, tp) > 0) {
+			tp += INADDRSZ;
+			saw_xdigit = 0;
+			break;	/* '\0' was seen by inet_pton4(). */
+		}
+		return (0);
+	}
+	if (saw_xdigit) {
+		if (tp + INT16SZ > endp)
+			return (0);
+		*tp++ = (u_char) (val >> 8) & 0xff;
+		*tp++ = (u_char) val & 0xff;
+	}
+	if (colonp != NULL) {
+		/*
+		 * Since some memmove()'s erroneously fail to handle
+		 * overlapping regions, we'll do the shift by hand.
+		 */
+		const int n = tp - colonp;
+		int i;
+
+		for (i = 1; i <= n; i++) {
+			endp[- i] = colonp[n - i];
+			colonp[n - i] = 0;
+		}
+		tp = endp;
+	}
+	if (tp != endp)
+		return (0);
+	/* bcopy(tmp, dst, IN6ADDRSZ); */
+	memcpy(dst, tmp, IN6ADDRSZ);
+	return (1);
+}
+
+#endif
+

Added: experimental/j/Elphel333/rtp/daemon/rtp/inet_pton.h
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/inet_pton.h	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/inet_pton.h	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,12 @@
+#ifndef HAVE_INET_PTON
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+int inet_pton(int af, const char *src, void *dst);
+
+#if defined(__cplusplus)
+}
+#endif
+#endif /* HAVE_INET_PTON */
+

Added: experimental/j/Elphel333/rtp/daemon/rtp/install-sh
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/install-sh	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/install-sh	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,250 @@
+#!/bin/sh
+#
+# install - install a program, script, or datafile
+# This comes from X11R5 (mit/util/scripts/install.sh).
+#
+# Copyright 1991 by the Massachusetts Institute of Technology
+#
+# Permission to use, copy, modify, distribute, and sell this software and its
+# documentation for any purpose is hereby granted without fee, provided that
+# the above copyright notice appear in all copies and that both that
+# copyright notice and this permission notice appear in supporting
+# documentation, and that the name of M.I.T. not be used in advertising or
+# publicity pertaining to distribution of the software without specific,
+# written prior permission.  M.I.T. makes no representations about the
+# suitability of this software for any purpose.  It is provided "as is"
+# without express or implied warranty.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch.  It can only install one file at a time, a restriction
+# shared with many OS's install programs.
+
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit="${DOITPROG-}"
+
+
+# put in absolute paths if you don't have them in your path; or use env. vars.
+
+mvprog="${MVPROG-mv}"
+cpprog="${CPPROG-cp}"
+chmodprog="${CHMODPROG-chmod}"
+chownprog="${CHOWNPROG-chown}"
+chgrpprog="${CHGRPPROG-chgrp}"
+stripprog="${STRIPPROG-strip}"
+rmprog="${RMPROG-rm}"
+mkdirprog="${MKDIRPROG-mkdir}"
+
+transformbasename=""
+transform_arg=""
+instcmd="$mvprog"
+chmodcmd="$chmodprog 0755"
+chowncmd=""
+chgrpcmd=""
+stripcmd=""
+rmcmd="$rmprog -f"
+mvcmd="$mvprog"
+src=""
+dst=""
+dir_arg=""
+
+while [ x"$1" != x ]; do
+    case $1 in
+	-c) instcmd="$cpprog"
+	    shift
+	    continue;;
+
+	-d) dir_arg=true
+	    shift
+	    continue;;
+
+	-m) chmodcmd="$chmodprog $2"
+	    shift
+	    shift
+	    continue;;
+
+	-o) chowncmd="$chownprog $2"
+	    shift
+	    shift
+	    continue;;
+
+	-g) chgrpcmd="$chgrpprog $2"
+	    shift
+	    shift
+	    continue;;
+
+	-s) stripcmd="$stripprog"
+	    shift
+	    continue;;
+
+	-t=*) transformarg=`echo $1 | sed 's/-t=//'`
+	    shift
+	    continue;;
+
+	-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
+	    shift
+	    continue;;
+
+	*)  if [ x"$src" = x ]
+	    then
+		src=$1
+	    else
+		# this colon is to work around a 386BSD /bin/sh bug
+		:
+		dst=$1
+	    fi
+	    shift
+	    continue;;
+    esac
+done
+
+if [ x"$src" = x ]
+then
+	echo "install:	no input file specified"
+	exit 1
+else
+	true
+fi
+
+if [ x"$dir_arg" != x ]; then
+	dst=$src
+	src=""
+	
+	if [ -d $dst ]; then
+		instcmd=:
+	else
+		instcmd=mkdir
+	fi
+else
+
+# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
+# might cause directories to be created, which would be especially bad 
+# if $src (and thus $dsttmp) contains '*'.
+
+	if [ -f $src -o -d $src ]
+	then
+		true
+	else
+		echo "install:  $src does not exist"
+		exit 1
+	fi
+	
+	if [ x"$dst" = x ]
+	then
+		echo "install:	no destination specified"
+		exit 1
+	else
+		true
+	fi
+
+# If destination is a directory, append the input filename; if your system
+# does not like double slashes in filenames, you may need to add some logic
+
+	if [ -d $dst ]
+	then
+		dst="$dst"/`basename $src`
+	else
+		true
+	fi
+fi
+
+## this sed command emulates the dirname command
+dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
+
+# Make sure that the destination directory exists.
+#  this part is taken from Noah Friedman's mkinstalldirs script
+
+# Skip lots of stat calls in the usual case.
+if [ ! -d "$dstdir" ]; then
+defaultIFS='	
+'
+IFS="${IFS-${defaultIFS}}"
+
+oIFS="${IFS}"
+# Some sh's can't handle IFS=/ for some reason.
+IFS='%'
+set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
+IFS="${oIFS}"
+
+pathcomp=''
+
+while [ $# -ne 0 ] ; do
+	pathcomp="${pathcomp}${1}"
+	shift
+
+	if [ ! -d "${pathcomp}" ] ;
+        then
+		$mkdirprog "${pathcomp}"
+	else
+		true
+	fi
+
+	pathcomp="${pathcomp}/"
+done
+fi
+
+if [ x"$dir_arg" != x ]
+then
+	$doit $instcmd $dst &&
+
+	if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
+	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
+	if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
+	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
+else
+
+# If we're going to rename the final executable, determine the name now.
+
+	if [ x"$transformarg" = x ] 
+	then
+		dstfile=`basename $dst`
+	else
+		dstfile=`basename $dst $transformbasename | 
+			sed $transformarg`$transformbasename
+	fi
+
+# don't allow the sed command to completely eliminate the filename
+
+	if [ x"$dstfile" = x ] 
+	then
+		dstfile=`basename $dst`
+	else
+		true
+	fi
+
+# Make a temp file name in the proper directory.
+
+	dsttmp=$dstdir/#inst.$$#
+
+# Move or copy the file name to the temp name
+
+	$doit $instcmd $src $dsttmp &&
+
+	trap "rm -f ${dsttmp}" 0 &&
+
+# and set any options; do chmod last to preserve setuid bits
+
+# If any of these fail, we abort the whole thing.  If we want to
+# ignore errors from any of these, just make sure not to ignore
+# errors from the above "$doit $instcmd $src $dsttmp" command.
+
+	if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
+	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
+	if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
+	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
+
+# Now rename the file to the real destination.
+
+	$doit $rmcmd -f $dstdir/$dstfile &&
+	$doit $mvcmd $dsttmp $dstdir/$dstfile 
+
+fi &&
+
+
+exit 0

Added: experimental/j/Elphel333/rtp/daemon/rtp/ltmain.sh
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/ltmain.sh	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/ltmain.sh	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,5064 @@
+# ltmain.sh - Provide generalized library-building support services.
+# NOTE: Changing this file will not affect anything until you rerun configure.
+#
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
+# Free Software Foundation, Inc.
+# Originally by Gordon Matzigkeit <gord at gnu.ai.mit.edu>, 1996
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Check that we have a working $echo.
+if test "X$1" = X--no-reexec; then
+  # Discard the --no-reexec flag, and continue.
+  shift
+elif test "X$1" = X--fallback-echo; then
+  # Avoid inline document here, it may be left over
+  :
+elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
+  # Yippee, $echo works!
+  :
+else
+  # Restart under the correct shell, and then maybe $echo will work.
+  exec $SHELL "$0" --no-reexec ${1+"$@"}
+fi
+
+if test "X$1" = X--fallback-echo; then
+  # used as fallback echo
+  shift
+  cat <<EOF
+$*
+EOF
+  exit 0
+fi
+
+# The name of this program.
+progname=`$echo "$0" | sed 's%^.*/%%'`
+modename="$progname"
+
+# Constants.
+PROGRAM=ltmain.sh
+PACKAGE=libtool
+VERSION=1.4.2
+TIMESTAMP=" (1.922.2.54 2001/09/11 03:33:37)"
+
+default_mode=
+help="Try \`$progname --help' for more information."
+magic="%%%MAGIC variable%%%"
+mkdir="mkdir"
+mv="mv -f"
+rm="rm -f"
+
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed='sed -e 1s/^X//'
+sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
+SP2NL='tr \040 \012'
+NL2SP='tr \015\012 \040\040'
+
+# NLS nuisances.
+# Only set LANG and LC_ALL to C if already set.
+# These must not be set unconditionally because not all systems understand
+# e.g. LANG=C (notably SCO).
+# We save the old values to restore during execute mode.
+if test "${LC_ALL+set}" = set; then
+  save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL
+fi
+if test "${LANG+set}" = set; then
+  save_LANG="$LANG"; LANG=C; export LANG
+fi
+
+# Make sure IFS has a sensible default
+: ${IFS=" 	"}
+
+if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
+  echo "$modename: not configured to build any kind of library" 1>&2
+  echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
+  exit 1
+fi
+
+# Global variables.
+mode=$default_mode
+nonopt=
+prev=
+prevopt=
+run=
+show="$echo"
+show_help=
+execute_dlfiles=
+lo2o="s/\\.lo\$/.${objext}/"
+o2lo="s/\\.${objext}\$/.lo/"
+
+# Parse our command line options once, thoroughly.
+while test $# -gt 0
+do
+  arg="$1"
+  shift
+
+  case $arg in
+  -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
+  *) optarg= ;;
+  esac
+
+  # If the previous option needs an argument, assign it.
+  if test -n "$prev"; then
+    case $prev in
+    execute_dlfiles)
+      execute_dlfiles="$execute_dlfiles $arg"
+      ;;
+    *)
+      eval "$prev=\$arg"
+      ;;
+    esac
+
+    prev=
+    prevopt=
+    continue
+  fi
+
+  # Have we seen a non-optional argument yet?
+  case $arg in
+  --help)
+    show_help=yes
+    ;;
+
+  --version)
+    echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"
+    exit 0
+    ;;
+
+  --config)
+    sed -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $0
+    exit 0
+    ;;
+
+  --debug)
+    echo "$progname: enabling shell trace mode"
+    set -x
+    ;;
+
+  --dry-run | -n)
+    run=:
+    ;;
+
+  --features)
+    echo "host: $host"
+    if test "$build_libtool_libs" = yes; then
+      echo "enable shared libraries"
+    else
+      echo "disable shared libraries"
+    fi
+    if test "$build_old_libs" = yes; then
+      echo "enable static libraries"
+    else
+      echo "disable static libraries"
+    fi
+    exit 0
+    ;;
+
+  --finish) mode="finish" ;;
+
+  --mode) prevopt="--mode" prev=mode ;;
+  --mode=*) mode="$optarg" ;;
+
+  --preserve-dup-deps) duplicate_deps="yes" ;;
+
+  --quiet | --silent)
+    show=:
+    ;;
+
+  -dlopen)
+    prevopt="-dlopen"
+    prev=execute_dlfiles
+    ;;
+
+  -*)
+    $echo "$modename: unrecognized option \`$arg'" 1>&2
+    $echo "$help" 1>&2
+    exit 1
+    ;;
+
+  *)
+    nonopt="$arg"
+    break
+    ;;
+  esac
+done
+
+if test -n "$prevopt"; then
+  $echo "$modename: option \`$prevopt' requires an argument" 1>&2
+  $echo "$help" 1>&2
+  exit 1
+fi
+
+# If this variable is set in any of the actions, the command in it
+# will be execed at the end.  This prevents here-documents from being
+# left over by shells.
+exec_cmd=
+
+if test -z "$show_help"; then
+
+  # Infer the operation mode.
+  if test -z "$mode"; then
+    case $nonopt in
+    *cc | *++ | gcc* | *-gcc*)
+      mode=link
+      for arg
+      do
+	case $arg in
+	-c)
+	   mode=compile
+	   break
+	   ;;
+	esac
+      done
+      ;;
+    *db | *dbx | *strace | *truss)
+      mode=execute
+      ;;
+    *install*|cp|mv)
+      mode=install
+      ;;
+    *rm)
+      mode=uninstall
+      ;;
+    *)
+      # If we have no mode, but dlfiles were specified, then do execute mode.
+      test -n "$execute_dlfiles" && mode=execute
+
+      # Just use the default operation mode.
+      if test -z "$mode"; then
+	if test -n "$nonopt"; then
+	  $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
+	else
+	  $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
+	fi
+      fi
+      ;;
+    esac
+  fi
+
+  # Only execute mode is allowed to have -dlopen flags.
+  if test -n "$execute_dlfiles" && test "$mode" != execute; then
+    $echo "$modename: unrecognized option \`-dlopen'" 1>&2
+    $echo "$help" 1>&2
+    exit 1
+  fi
+
+  # Change the help message to a mode-specific one.
+  generic_help="$help"
+  help="Try \`$modename --help --mode=$mode' for more information."
+
+  # These modes are in order of execution frequency so that they run quickly.
+  case $mode in
+  # libtool compile mode
+  compile)
+    modename="$modename: compile"
+    # Get the compilation command and the source file.
+    base_compile=
+    prev=
+    lastarg=
+    srcfile="$nonopt"
+    suppress_output=
+
+    user_target=no
+    for arg
+    do
+      case $prev in
+      "") ;;
+      xcompiler)
+	# Aesthetically quote the previous argument.
+	prev=
+	lastarg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
+
+	case $arg in
+	# Double-quote args containing other shell metacharacters.
+	# Many Bourne shells cannot handle close brackets correctly
+	# in scan sets, so we specify it separately.
+	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
+	  arg="\"$arg\""
+	  ;;
+	esac
+
+	# Add the previous argument to base_compile.
+	if test -z "$base_compile"; then
+	  base_compile="$lastarg"
+	else
+	  base_compile="$base_compile $lastarg"
+	fi
+	continue
+	;;
+      esac
+
+      # Accept any command-line options.
+      case $arg in
+      -o)
+	if test "$user_target" != "no"; then
+	  $echo "$modename: you cannot specify \`-o' more than once" 1>&2
+	  exit 1
+	fi
+	user_target=next
+	;;
+
+      -static)
+	build_old_libs=yes
+	continue
+	;;
+
+      -prefer-pic)
+	pic_mode=yes
+	continue
+	;;
+
+      -prefer-non-pic)
+	pic_mode=no
+	continue
+	;;
+
+      -Xcompiler)
+	prev=xcompiler
+	continue
+	;;
+
+      -Wc,*)
+	args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`
+	lastarg=
+	save_ifs="$IFS"; IFS=','
+	for arg in $args; do
+	  IFS="$save_ifs"
+
+	  # Double-quote args containing other shell metacharacters.
+	  # Many Bourne shells cannot handle close brackets correctly
+	  # in scan sets, so we specify it separately.
+	  case $arg in
+	    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
+	    arg="\"$arg\""
+	    ;;
+	  esac
+	  lastarg="$lastarg $arg"
+	done
+	IFS="$save_ifs"
+	lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"`
+
+	# Add the arguments to base_compile.
+	if test -z "$base_compile"; then
+	  base_compile="$lastarg"
+	else
+	  base_compile="$base_compile $lastarg"
+	fi
+	continue
+	;;
+      esac
+
+      case $user_target in
+      next)
+	# The next one is the -o target name
+	user_target=yes
+	continue
+	;;
+      yes)
+	# We got the output file
+	user_target=set
+	libobj="$arg"
+	continue
+	;;
+      esac
+
+      # Accept the current argument as the source file.
+      lastarg="$srcfile"
+      srcfile="$arg"
+
+      # Aesthetically quote the previous argument.
+
+      # Backslashify any backslashes, double quotes, and dollar signs.
+      # These are the only characters that are still specially
+      # interpreted inside of double-quoted scrings.
+      lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
+
+      # Double-quote args containing other shell metacharacters.
+      # Many Bourne shells cannot handle close brackets correctly
+      # in scan sets, so we specify it separately.
+      case $lastarg in
+      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
+	lastarg="\"$lastarg\""
+	;;
+      esac
+
+      # Add the previous argument to base_compile.
+      if test -z "$base_compile"; then
+	base_compile="$lastarg"
+      else
+	base_compile="$base_compile $lastarg"
+      fi
+    done
+
+    case $user_target in
+    set)
+      ;;
+    no)
+      # Get the name of the library object.
+      libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
+      ;;
+    *)
+      $echo "$modename: you must specify a target with \`-o'" 1>&2
+      exit 1
+      ;;
+    esac
+
+    # Recognize several different file suffixes.
+    # If the user specifies -o file.o, it is replaced with file.lo
+    xform='[cCFSfmso]'
+    case $libobj in
+    *.ada) xform=ada ;;
+    *.adb) xform=adb ;;
+    *.ads) xform=ads ;;
+    *.asm) xform=asm ;;
+    *.c++) xform=c++ ;;
+    *.cc) xform=cc ;;
+    *.cpp) xform=cpp ;;
+    *.cxx) xform=cxx ;;
+    *.f90) xform=f90 ;;
+    *.for) xform=for ;;
+    esac
+
+    libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
+
+    case $libobj in
+    *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
+    *)
+      $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
+      exit 1
+      ;;
+    esac
+
+    if test -z "$base_compile"; then
+      $echo "$modename: you must specify a compilation command" 1>&2
+      $echo "$help" 1>&2
+      exit 1
+    fi
+
+    # Delete any leftover library objects.
+    if test "$build_old_libs" = yes; then
+      removelist="$obj $libobj"
+    else
+      removelist="$libobj"
+    fi
+
+    $run $rm $removelist
+    trap "$run $rm $removelist; exit 1" 1 2 15
+
+    # On Cygwin there's no "real" PIC flag so we must build both object types
+    case $host_os in
+    cygwin* | mingw* | pw32* | os2*)
+      pic_mode=default
+      ;;
+    esac
+    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
+      # non-PIC code in shared libraries is not supported
+      pic_mode=default
+    fi
+
+    # Calculate the filename of the output object if compiler does
+    # not support -o with -c
+    if test "$compiler_c_o" = no; then
+      output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
+      lockfile="$output_obj.lock"
+      removelist="$removelist $output_obj $lockfile"
+      trap "$run $rm $removelist; exit 1" 1 2 15
+    else
+      need_locks=no
+      lockfile=
+    fi
+
+    # Lock this critical section if it is needed
+    # We use this script file to make the link, it avoids creating a new file
+    if test "$need_locks" = yes; then
+      until $run ln "$0" "$lockfile" 2>/dev/null; do
+	$show "Waiting for $lockfile to be removed"
+	sleep 2
+      done
+    elif test "$need_locks" = warn; then
+      if test -f "$lockfile"; then
+	echo "\
+*** ERROR, $lockfile exists and contains:
+`cat $lockfile 2>/dev/null`
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together.  If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+	$run $rm $removelist
+	exit 1
+      fi
+      echo $srcfile > "$lockfile"
+    fi
+
+    if test -n "$fix_srcfile_path"; then
+      eval srcfile=\"$fix_srcfile_path\"
+    fi
+
+    # Only build a PIC object if we are building libtool libraries.
+    if test "$build_libtool_libs" = yes; then
+      # Without this assignment, base_compile gets emptied.
+      fbsd_hideous_sh_bug=$base_compile
+
+      if test "$pic_mode" != no; then
+	# All platforms use -DPIC, to notify preprocessed assembler code.
+	command="$base_compile $srcfile $pic_flag -DPIC"
+      else
+	# Don't build PIC code
+	command="$base_compile $srcfile"
+      fi
+      if test "$build_old_libs" = yes; then
+	lo_libobj="$libobj"
+	dir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'`
+	if test "X$dir" = "X$libobj"; then
+	  dir="$objdir"
+	else
+	  dir="$dir/$objdir"
+	fi
+	libobj="$dir/"`$echo "X$libobj" | $Xsed -e 's%^.*/%%'`
+
+	if test -d "$dir"; then
+	  $show "$rm $libobj"
+	  $run $rm $libobj
+	else
+	  $show "$mkdir $dir"
+	  $run $mkdir $dir
+	  status=$?
+	  if test $status -ne 0 && test ! -d $dir; then
+	    exit $status
+	  fi
+	fi
+      fi
+      if test "$compiler_o_lo" = yes; then
+	output_obj="$libobj"
+	command="$command -o $output_obj"
+      elif test "$compiler_c_o" = yes; then
+	output_obj="$obj"
+	command="$command -o $output_obj"
+      fi
+
+      $run $rm "$output_obj"
+      $show "$command"
+      if $run eval "$command"; then :
+      else
+	test -n "$output_obj" && $run $rm $removelist
+	exit 1
+      fi
+
+      if test "$need_locks" = warn &&
+	 test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then
+	echo "\
+*** ERROR, $lockfile contains:
+`cat $lockfile 2>/dev/null`
+
+but it should contain:
+$srcfile
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together.  If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+	$run $rm $removelist
+	exit 1
+      fi
+
+      # Just move the object if needed, then go on to compile the next one
+      if test x"$output_obj" != x"$libobj"; then
+	$show "$mv $output_obj $libobj"
+	if $run $mv $output_obj $libobj; then :
+	else
+	  error=$?
+	  $run $rm $removelist
+	  exit $error
+	fi
+      fi
+
+      # If we have no pic_flag, then copy the object into place and finish.
+      if (test -z "$pic_flag" || test "$pic_mode" != default) &&
+	 test "$build_old_libs" = yes; then
+	# Rename the .lo from within objdir to obj
+	if test -f $obj; then
+	  $show $rm $obj
+	  $run $rm $obj
+	fi
+
+	$show "$mv $libobj $obj"
+	if $run $mv $libobj $obj; then :
+	else
+	  error=$?
+	  $run $rm $removelist
+	  exit $error
+	fi
+
+	xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
+	if test "X$xdir" = "X$obj"; then
+	  xdir="."
+	else
+	  xdir="$xdir"
+	fi
+	baseobj=`$echo "X$obj" | $Xsed -e "s%.*/%%"`
+	libobj=`$echo "X$baseobj" | $Xsed -e "$o2lo"`
+	# Now arrange that obj and lo_libobj become the same file
+	$show "(cd $xdir && $LN_S $baseobj $libobj)"
+	if $run eval '(cd $xdir && $LN_S $baseobj $libobj)'; then
+	  # Unlock the critical section if it was locked
+	  if test "$need_locks" != no; then
+	    $run $rm "$lockfile"
+	  fi
+	  exit 0
+	else
+	  error=$?
+	  $run $rm $removelist
+	  exit $error
+	fi
+      fi
+
+      # Allow error messages only from the first compilation.
+      suppress_output=' >/dev/null 2>&1'
+    fi
+
+    # Only build a position-dependent object if we build old libraries.
+    if test "$build_old_libs" = yes; then
+      if test "$pic_mode" != yes; then
+	# Don't build PIC code
+	command="$base_compile $srcfile"
+      else
+	# All platforms use -DPIC, to notify preprocessed assembler code.
+	command="$base_compile $srcfile $pic_flag -DPIC"
+      fi
+      if test "$compiler_c_o" = yes; then
+	command="$command -o $obj"
+	output_obj="$obj"
+      fi
+
+      # Suppress compiler output if we already did a PIC compilation.
+      command="$command$suppress_output"
+      $run $rm "$output_obj"
+      $show "$command"
+      if $run eval "$command"; then :
+      else
+	$run $rm $removelist
+	exit 1
+      fi
+
+      if test "$need_locks" = warn &&
+	 test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then
+	echo "\
+*** ERROR, $lockfile contains:
+`cat $lockfile 2>/dev/null`
+
+but it should contain:
+$srcfile
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together.  If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+	$run $rm $removelist
+	exit 1
+      fi
+
+      # Just move the object if needed
+      if test x"$output_obj" != x"$obj"; then
+	$show "$mv $output_obj $obj"
+	if $run $mv $output_obj $obj; then :
+	else
+	  error=$?
+	  $run $rm $removelist
+	  exit $error
+	fi
+      fi
+
+      # Create an invalid libtool object if no PIC, so that we do not
+      # accidentally link it into a program.
+      if test "$build_libtool_libs" != yes; then
+	$show "echo timestamp > $libobj"
+	$run eval "echo timestamp > \$libobj" || exit $?
+      else
+	# Move the .lo from within objdir
+	$show "$mv $libobj $lo_libobj"
+	if $run $mv $libobj $lo_libobj; then :
+	else
+	  error=$?
+	  $run $rm $removelist
+	  exit $error
+	fi
+      fi
+    fi
+
+    # Unlock the critical section if it was locked
+    if test "$need_locks" != no; then
+      $run $rm "$lockfile"
+    fi
+
+    exit 0
+    ;;
+
+  # libtool link mode
+  link | relink)
+    modename="$modename: link"
+    case $host in
+    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
+      # It is impossible to link a dll without this setting, and
+      # we shouldn't force the makefile maintainer to figure out
+      # which system we are compiling for in order to pass an extra
+      # flag for every libtool invokation.
+      # allow_undefined=no
+
+      # FIXME: Unfortunately, there are problems with the above when trying
+      # to make a dll which has undefined symbols, in which case not
+      # even a static library is built.  For now, we need to specify
+      # -no-undefined on the libtool link line when we can be certain
+      # that all symbols are satisfied, otherwise we get a static library.
+      allow_undefined=yes
+      ;;
+    *)
+      allow_undefined=yes
+      ;;
+    esac
+    libtool_args="$nonopt"
+    compile_command="$nonopt"
+    finalize_command="$nonopt"
+
+    compile_rpath=
+    finalize_rpath=
+    compile_shlibpath=
+    finalize_shlibpath=
+    convenience=
+    old_convenience=
+    deplibs=
+    old_deplibs=
+    compiler_flags=
+    linker_flags=
+    dllsearchpath=
+    lib_search_path=`pwd`
+    inst_prefix_dir=
+
+    avoid_version=no
+    dlfiles=
+    dlprefiles=
+    dlself=no
+    export_dynamic=no
+    export_symbols=
+    export_symbols_regex=
+    generated=
+    libobjs=
+    ltlibs=
+    module=no
+    no_install=no
+    objs=
+    prefer_static_libs=no
+    preload=no
+    prev=
+    prevarg=
+    release=
+    rpath=
+    xrpath=
+    perm_rpath=
+    temp_rpath=
+    thread_safe=no
+    vinfo=
+
+    # We need to know -static, to get the right output filenames.
+    for arg
+    do
+      case $arg in
+      -all-static | -static)
+	if test "X$arg" = "X-all-static"; then
+	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
+	    $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
+	  fi
+	  if test -n "$link_static_flag"; then
+	    dlopen_self=$dlopen_self_static
+	  fi
+	else
+	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
+	    dlopen_self=$dlopen_self_static
+	  fi
+	fi
+	build_libtool_libs=no
+	build_old_libs=yes
+	prefer_static_libs=yes
+	break
+	;;
+      esac
+    done
+
+    # See if our shared archives depend on static archives.
+    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
+
+    # Go through the arguments, transforming them on the way.
+    while test $# -gt 0; do
+      arg="$1"
+      shift
+      case $arg in
+      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
+	qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test
+	;;
+      *) qarg=$arg ;;
+      esac
+      libtool_args="$libtool_args $qarg"
+
+      # If the previous option needs an argument, assign it.
+      if test -n "$prev"; then
+	case $prev in
+	output)
+	  compile_command="$compile_command @OUTPUT@"
+	  finalize_command="$finalize_command @OUTPUT@"
+	  ;;
+	esac
+
+	case $prev in
+	dlfiles|dlprefiles)
+	  if test "$preload" = no; then
+	    # Add the symbol object into the linking commands.
+	    compile_command="$compile_command @SYMFILE@"
+	    finalize_command="$finalize_command @SYMFILE@"
+	    preload=yes
+	  fi
+	  case $arg in
+	  *.la | *.lo) ;;  # We handle these cases below.
+	  force)
+	    if test "$dlself" = no; then
+	      dlself=needless
+	      export_dynamic=yes
+	    fi
+	    prev=
+	    continue
+	    ;;
+	  self)
+	    if test "$prev" = dlprefiles; then
+	      dlself=yes
+	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
+	      dlself=yes
+	    else
+	      dlself=needless
+	      export_dynamic=yes
+	    fi
+	    prev=
+	    continue
+	    ;;
+	  *)
+	    if test "$prev" = dlfiles; then
+	      dlfiles="$dlfiles $arg"
+	    else
+	      dlprefiles="$dlprefiles $arg"
+	    fi
+	    prev=
+	    continue
+	    ;;
+	  esac
+	  ;;
+	expsyms)
+	  export_symbols="$arg"
+	  if test ! -f "$arg"; then
+	    $echo "$modename: symbol file \`$arg' does not exist"
+	    exit 1
+	  fi
+	  prev=
+	  continue
+	  ;;
+	expsyms_regex)
+	  export_symbols_regex="$arg"
+	  prev=
+	  continue
+	  ;;
+        inst_prefix)
+	  inst_prefix_dir="$arg"
+	  prev=
+	  continue
+	  ;;
+	release)
+	  release="-$arg"
+	  prev=
+	  continue
+	  ;;
+	rpath | xrpath)
+	  # We need an absolute path.
+	  case $arg in
+	  [\\/]* | [A-Za-z]:[\\/]*) ;;
+	  *)
+	    $echo "$modename: only absolute run-paths are allowed" 1>&2
+	    exit 1
+	    ;;
+	  esac
+	  if test "$prev" = rpath; then
+	    case "$rpath " in
+	    *" $arg "*) ;;
+	    *) rpath="$rpath $arg" ;;
+	    esac
+	  else
+	    case "$xrpath " in
+	    *" $arg "*) ;;
+	    *) xrpath="$xrpath $arg" ;;
+	    esac
+	  fi
+	  prev=
+	  continue
+	  ;;
+	xcompiler)
+	  compiler_flags="$compiler_flags $qarg"
+	  prev=
+	  compile_command="$compile_command $qarg"
+	  finalize_command="$finalize_command $qarg"
+	  continue
+	  ;;
+	xlinker)
+	  linker_flags="$linker_flags $qarg"
+	  compiler_flags="$compiler_flags $wl$qarg"
+	  prev=
+	  compile_command="$compile_command $wl$qarg"
+	  finalize_command="$finalize_command $wl$qarg"
+	  continue
+	  ;;
+	*)
+	  eval "$prev=\"\$arg\""
+	  prev=
+	  continue
+	  ;;
+	esac
+      fi # test -n $prev
+
+      prevarg="$arg"
+
+      case $arg in
+      -all-static)
+	if test -n "$link_static_flag"; then
+	  compile_command="$compile_command $link_static_flag"
+	  finalize_command="$finalize_command $link_static_flag"
+	fi
+	continue
+	;;
+
+      -allow-undefined)
+	# FIXME: remove this flag sometime in the future.
+	$echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2
+	continue
+	;;
+
+      -avoid-version)
+	avoid_version=yes
+	continue
+	;;
+
+      -dlopen)
+	prev=dlfiles
+	continue
+	;;
+
+      -dlpreopen)
+	prev=dlprefiles
+	continue
+	;;
+
+      -export-dynamic)
+	export_dynamic=yes
+	continue
+	;;
+
+      -export-symbols | -export-symbols-regex)
+	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
+	  $echo "$modename: more than one -exported-symbols argument is not allowed"
+	  exit 1
+	fi
+	if test "X$arg" = "X-export-symbols"; then
+	  prev=expsyms
+	else
+	  prev=expsyms_regex
+	fi
+	continue
+	;;
+
+      -inst-prefix-dir)
+	prev=inst_prefix
+	continue
+	;;
+
+      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
+      # so, if we see these flags be careful not to treat them like -L
+      -L[A-Z][A-Z]*:*)
+	case $with_gcc/$host in
+	no/*-*-irix*)
+	  compile_command="$compile_command $arg"
+	  finalize_command="$finalize_command $arg"
+	  ;;
+	esac
+	continue
+	;;
+
+      -L*)
+	dir=`$echo "X$arg" | $Xsed -e 's/^-L//'`
+	# We need an absolute path.
+	case $dir in
+	[\\/]* | [A-Za-z]:[\\/]*) ;;
+	*)
+	  absdir=`cd "$dir" && pwd`
+	  if test -z "$absdir"; then
+	    $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2
+	    exit 1
+	  fi
+	  dir="$absdir"
+	  ;;
+	esac
+	case "$deplibs " in
+	*" -L$dir "*) ;;
+	*)
+	  deplibs="$deplibs -L$dir"
+	  lib_search_path="$lib_search_path $dir"
+	  ;;
+	esac
+	case $host in
+	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
+	  case :$dllsearchpath: in
+	  *":$dir:"*) ;;
+	  *) dllsearchpath="$dllsearchpath:$dir";;
+	  esac
+	  ;;
+	esac
+	continue
+	;;
+
+      -l*)
+	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
+	  case $host in
+	  *-*-cygwin* | *-*-pw32* | *-*-beos*)
+	    # These systems don't actually have a C or math library (as such)
+	    continue
+	    ;;
+	  *-*-mingw* | *-*-os2*)
+	    # These systems don't actually have a C library (as such)
+	    test "X$arg" = "X-lc" && continue
+	    ;;
+	  *-*-openbsd*)
+	    # Do not include libc due to us having libc/libc_r.
+	    test "X$arg" = "X-lc" && continue
+	    ;;
+	  esac
+	 elif test "X$arg" = "X-lc_r"; then
+	  case $host in
+	  *-*-openbsd*)
+	    # Do not include libc_r directly, use -pthread flag.
+	    continue
+	    ;;
+	  esac
+	fi
+	deplibs="$deplibs $arg"
+	continue
+	;;
+
+      -module)
+	module=yes
+	continue
+	;;
+
+      -no-fast-install)
+	fast_install=no
+	continue
+	;;
+
+      -no-install)
+	case $host in
+	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
+	  # The PATH hackery in wrapper scripts is required on Windows
+	  # in order for the loader to find any dlls it needs.
+	  $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2
+	  $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2
+	  fast_install=no
+	  ;;
+	*) no_install=yes ;;
+	esac
+	continue
+	;;
+
+      -no-undefined)
+	allow_undefined=no
+	continue
+	;;
+
+      -o) prev=output ;;
+
+      -release)
+	prev=release
+	continue
+	;;
+
+      -rpath)
+	prev=rpath
+	continue
+	;;
+
+      -R)
+	prev=xrpath
+	continue
+	;;
+
+      -R*)
+	dir=`$echo "X$arg" | $Xsed -e 's/^-R//'`
+	# We need an absolute path.
+	case $dir in
+	[\\/]* | [A-Za-z]:[\\/]*) ;;
+	*)
+	  $echo "$modename: only absolute run-paths are allowed" 1>&2
+	  exit 1
+	  ;;
+	esac
+	case "$xrpath " in
+	*" $dir "*) ;;
+	*) xrpath="$xrpath $dir" ;;
+	esac
+	continue
+	;;
+
+      -static)
+	# The effects of -static are defined in a previous loop.
+	# We used to do the same as -all-static on platforms that
+	# didn't have a PIC flag, but the assumption that the effects
+	# would be equivalent was wrong.  It would break on at least
+	# Digital Unix and AIX.
+	continue
+	;;
+
+      -thread-safe)
+	thread_safe=yes
+	continue
+	;;
+
+      -version-info)
+	prev=vinfo
+	continue
+	;;
+
+      -Wc,*)
+	args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'`
+	arg=
+	save_ifs="$IFS"; IFS=','
+	for flag in $args; do
+	  IFS="$save_ifs"
+	  case $flag in
+	    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
+	    flag="\"$flag\""
+	    ;;
+	  esac
+	  arg="$arg $wl$flag"
+	  compiler_flags="$compiler_flags $flag"
+	done
+	IFS="$save_ifs"
+	arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
+	;;
+
+      -Wl,*)
+	args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'`
+	arg=
+	save_ifs="$IFS"; IFS=','
+	for flag in $args; do
+	  IFS="$save_ifs"
+	  case $flag in
+	    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
+	    flag="\"$flag\""
+	    ;;
+	  esac
+	  arg="$arg $wl$flag"
+	  compiler_flags="$compiler_flags $wl$flag"
+	  linker_flags="$linker_flags $flag"
+	done
+	IFS="$save_ifs"
+	arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
+	;;
+
+      -Xcompiler)
+	prev=xcompiler
+	continue
+	;;
+
+      -Xlinker)
+	prev=xlinker
+	continue
+	;;
+
+      # Some other compiler flag.
+      -* | +*)
+	# Unknown arguments in both finalize_command and compile_command need
+	# to be aesthetically quoted because they are evaled later.
+	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
+	case $arg in
+	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
+	  arg="\"$arg\""
+	  ;;
+	esac
+	;;
+
+      *.lo | *.$objext)
+	# A library or standard object.
+	if test "$prev" = dlfiles; then
+	  # This file was specified with -dlopen.
+	  if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+	    dlfiles="$dlfiles $arg"
+	    prev=
+	    continue
+	  else
+	    # If libtool objects are unsupported, then we need to preload.
+	    prev=dlprefiles
+	  fi
+	fi
+
+	if test "$prev" = dlprefiles; then
+	  # Preload the old-style object.
+	  dlprefiles="$dlprefiles "`$echo "X$arg" | $Xsed -e "$lo2o"`
+	  prev=
+	else
+	  case $arg in
+	  *.lo) libobjs="$libobjs $arg" ;;
+	  *) objs="$objs $arg" ;;
+	  esac
+	fi
+	;;
+
+      *.$libext)
+	# An archive.
+	deplibs="$deplibs $arg"
+	old_deplibs="$old_deplibs $arg"
+	continue
+	;;
+
+      *.la)
+	# A libtool-controlled library.
+
+	if test "$prev" = dlfiles; then
+	  # This library was specified with -dlopen.
+	  dlfiles="$dlfiles $arg"
+	  prev=
+	elif test "$prev" = dlprefiles; then
+	  # The library was specified with -dlpreopen.
+	  dlprefiles="$dlprefiles $arg"
+	  prev=
+	else
+	  deplibs="$deplibs $arg"
+	fi
+	continue
+	;;
+
+      # Some other compiler argument.
+      *)
+	# Unknown arguments in both finalize_command and compile_command need
+	# to be aesthetically quoted because they are evaled later.
+	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
+	case $arg in
+	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
+	  arg="\"$arg\""
+	  ;;
+	esac
+	;;
+      esac # arg
+
+      # Now actually substitute the argument into the commands.
+      if test -n "$arg"; then
+	compile_command="$compile_command $arg"
+	finalize_command="$finalize_command $arg"
+      fi
+    done # argument parsing loop
+
+    if test -n "$prev"; then
+      $echo "$modename: the \`$prevarg' option requires an argument" 1>&2
+      $echo "$help" 1>&2
+      exit 1
+    fi
+
+    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
+      eval arg=\"$export_dynamic_flag_spec\"
+      compile_command="$compile_command $arg"
+      finalize_command="$finalize_command $arg"
+    fi
+
+    # calculate the name of the file, without its directory
+    outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'`
+    libobjs_save="$libobjs"
+
+    if test -n "$shlibpath_var"; then
+      # get the directories listed in $shlibpath_var
+      eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
+    else
+      shlib_search_path=
+    fi
+    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
+    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
+
+    output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
+    if test "X$output_objdir" = "X$output"; then
+      output_objdir="$objdir"
+    else
+      output_objdir="$output_objdir/$objdir"
+    fi
+    # Create the object directory.
+    if test ! -d "$output_objdir"; then
+      $show "$mkdir $output_objdir"
+      $run $mkdir $output_objdir
+      status=$?
+      if test "$status" -ne 0 && test ! -d "$output_objdir"; then
+	exit $status
+      fi
+    fi
+
+    # Determine the type of output
+    case $output in
+    "")
+      $echo "$modename: you must specify an output file" 1>&2
+      $echo "$help" 1>&2
+      exit 1
+      ;;
+    *.$libext) linkmode=oldlib ;;
+    *.lo | *.$objext) linkmode=obj ;;
+    *.la) linkmode=lib ;;
+    *) linkmode=prog ;; # Anything else should be a program.
+    esac
+
+    specialdeplibs=
+    libs=
+    # Find all interdependent deplibs by searching for libraries
+    # that are linked more than once (e.g. -la -lb -la)
+    for deplib in $deplibs; do
+      if test "X$duplicate_deps" = "Xyes" ; then
+	case "$libs " in
+	*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+	esac
+      fi
+      libs="$libs $deplib"
+    done
+
+    if test "$linkmode" = lib; then
+      libs="$predeps $libs $compiler_lib_search_path $postdeps"
+
+      # Compute libraries that are listed more than once in $predeps
+      # $postdeps and mark them as special (i.e., whose duplicates are
+      # not to be eliminated).
+      pre_post_deps=
+      if test "X$duplicate_deps" = "Xyes" ; then
+	for pre_post_dep in $predeps $postdeps; do
+	  case "$pre_post_deps " in
+	  *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
+	  esac
+	  pre_post_deps="$pre_post_deps $pre_post_dep"
+	done
+      fi
+      pre_post_deps=
+    fi
+
+    deplibs=
+    newdependency_libs=
+    newlib_search_path=
+    need_relink=no # whether we're linking any uninstalled libtool libraries
+    notinst_deplibs= # not-installed libtool libraries
+    notinst_path= # paths that contain not-installed libtool libraries
+    case $linkmode in
+    lib)
+	passes="conv link"
+	for file in $dlfiles $dlprefiles; do
+	  case $file in
+	  *.la) ;;
+	  *)
+	    $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2
+	    exit 1
+	    ;;
+	  esac
+	done
+	;;
+    prog)
+	compile_deplibs=
+	finalize_deplibs=
+	alldeplibs=no
+	newdlfiles=
+	newdlprefiles=
+	passes="conv scan dlopen dlpreopen link"
+	;;
+    *)  passes="conv"
+	;;
+    esac
+    for pass in $passes; do
+      if test "$linkmode" = prog; then
+	# Determine which files to process
+	case $pass in
+	dlopen)
+	  libs="$dlfiles"
+	  save_deplibs="$deplibs" # Collect dlpreopened libraries
+	  deplibs=
+	  ;;
+	dlpreopen) libs="$dlprefiles" ;;
+	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
+	esac
+      fi
+      for deplib in $libs; do
+	lib=
+	found=no
+	case $deplib in
+	-l*)
+	  if test "$linkmode" = oldlib && test "$linkmode" = obj; then
+	    $echo "$modename: warning: \`-l' is ignored for archives/objects: $deplib" 1>&2
+	    continue
+	  fi
+	  if test "$pass" = conv; then
+	    deplibs="$deplib $deplibs"
+	    continue
+	  fi
+	  name=`$echo "X$deplib" | $Xsed -e 's/^-l//'`
+	  for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do
+	    # Search the libtool library
+	    lib="$searchdir/lib${name}.la"
+	    if test -f "$lib"; then
+	      found=yes
+	      break
+	    fi
+	  done
+	  if test "$found" != yes; then
+	    # deplib doesn't seem to be a libtool library
+	    if test "$linkmode,$pass" = "prog,link"; then
+	      compile_deplibs="$deplib $compile_deplibs"
+	      finalize_deplibs="$deplib $finalize_deplibs"
+	    else
+	      deplibs="$deplib $deplibs"
+	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
+	    fi
+	    continue
+	  fi
+	  ;; # -l
+	-L*)
+	  case $linkmode in
+	  lib)
+	    deplibs="$deplib $deplibs"
+	    test "$pass" = conv && continue
+	    newdependency_libs="$deplib $newdependency_libs"
+	    newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
+	    ;;
+	  prog)
+	    if test "$pass" = conv; then
+	      deplibs="$deplib $deplibs"
+	      continue
+	    fi
+	    if test "$pass" = scan; then
+	      deplibs="$deplib $deplibs"
+	      newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
+	    else
+	      compile_deplibs="$deplib $compile_deplibs"
+	      finalize_deplibs="$deplib $finalize_deplibs"
+	    fi
+	    ;;
+	  *)
+	    $echo "$modename: warning: \`-L' is ignored for archives/objects: $deplib" 1>&2
+	    ;;
+	  esac # linkmode
+	  continue
+	  ;; # -L
+	-R*)
+	  if test "$pass" = link; then
+	    dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'`
+	    # Make sure the xrpath contains only unique directories.
+	    case "$xrpath " in
+	    *" $dir "*) ;;
+	    *) xrpath="$xrpath $dir" ;;
+	    esac
+	  fi
+	  deplibs="$deplib $deplibs"
+	  continue
+	  ;;
+	*.la) lib="$deplib" ;;
+	*.$libext)
+	  if test "$pass" = conv; then
+	    deplibs="$deplib $deplibs"
+	    continue
+	  fi
+	  case $linkmode in
+	  lib)
+	    if test "$deplibs_check_method" != pass_all; then
+	      echo
+	      echo "*** Warning: This library needs some functionality provided by $deplib."
+	      echo "*** I have the capability to make that library automatically link in when"
+	      echo "*** you link to this library.  But I can only do this if you have a"
+	      echo "*** shared version of the library, which you do not appear to have."
+	    else
+	      echo
+	      echo "*** Warning: Linking the shared library $output against the"
+	      echo "*** static library $deplib is not portable!"
+	      deplibs="$deplib $deplibs"
+	    fi
+	    continue
+	    ;;
+	  prog)
+	    if test "$pass" != link; then
+	      deplibs="$deplib $deplibs"
+	    else
+	      compile_deplibs="$deplib $compile_deplibs"
+	      finalize_deplibs="$deplib $finalize_deplibs"
+	    fi
+	    continue
+	    ;;
+	  esac # linkmode
+	  ;; # *.$libext
+	*.lo | *.$objext)
+	  if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
+	    # If there is no dlopen support or we're linking statically,
+	    # we need to preload.
+	    newdlprefiles="$newdlprefiles $deplib"
+	    compile_deplibs="$deplib $compile_deplibs"
+	    finalize_deplibs="$deplib $finalize_deplibs"
+	  else
+	    newdlfiles="$newdlfiles $deplib"
+	  fi
+	  continue
+	  ;;
+	%DEPLIBS%)
+	  alldeplibs=yes
+	  continue
+	  ;;
+	esac # case $deplib
+	if test "$found" = yes || test -f "$lib"; then :
+	else
+	  $echo "$modename: cannot find the library \`$lib'" 1>&2
+	  exit 1
+	fi
+
+	# Check to see that this really is a libtool archive.
+	if (sed -e '2q' $lib | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
+	else
+	  $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
+	  exit 1
+	fi
+
+	ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
+	test "X$ladir" = "X$lib" && ladir="."
+
+	dlname=
+	dlopen=
+	dlpreopen=
+	libdir=
+	library_names=
+	old_library=
+	# If the library was installed with an old release of libtool,
+	# it will not redefine variable installed.
+	installed=yes
+
+	# Read the .la file
+	case $lib in
+	*/* | *\\*) . $lib ;;
+	*) . ./$lib ;;
+	esac
+
+	if test "$linkmode,$pass" = "lib,link" ||
+	   test "$linkmode,$pass" = "prog,scan" ||
+	   { test "$linkmode" = oldlib && test "$linkmode" = obj; }; then
+	   # Add dl[pre]opened files of deplib
+	  test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
+	  test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
+	fi
+
+	if test "$pass" = conv; then
+	  # Only check for convenience libraries
+	  deplibs="$lib $deplibs"
+	  if test -z "$libdir"; then
+	    if test -z "$old_library"; then
+	      $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
+	      exit 1
+	    fi
+	    # It is a libtool convenience library, so add in its objects.
+	    convenience="$convenience $ladir/$objdir/$old_library"
+	    old_convenience="$old_convenience $ladir/$objdir/$old_library"
+	    tmp_libs=
+	    for deplib in $dependency_libs; do
+	      deplibs="$deplib $deplibs"
+              if test "X$duplicate_deps" = "Xyes" ; then
+	        case "$tmp_libs " in
+	        *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+	        esac
+              fi
+	      tmp_libs="$tmp_libs $deplib"
+	    done
+	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
+	    $echo "$modename: \`$lib' is not a convenience library" 1>&2
+	    exit 1
+	  fi
+	  continue
+	fi # $pass = conv
+
+	# Get the name of the library we link against.
+	linklib=
+	for l in $old_library $library_names; do
+	  linklib="$l"
+	done
+	if test -z "$linklib"; then
+	  $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
+	  exit 1
+	fi
+
+	# This library was specified with -dlopen.
+	if test "$pass" = dlopen; then
+	  if test -z "$libdir"; then
+	    $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2
+	    exit 1
+	  fi
+	  if test -z "$dlname" || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
+	    # If there is no dlname, no dlopen support or we're linking
+	    # statically, we need to preload.
+	    dlprefiles="$dlprefiles $lib"
+	  else
+	    newdlfiles="$newdlfiles $lib"
+	  fi
+	  continue
+	fi # $pass = dlopen
+
+	# We need an absolute path.
+	case $ladir in
+	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
+	*)
+	  abs_ladir=`cd "$ladir" && pwd`
+	  if test -z "$abs_ladir"; then
+	    $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2
+	    $echo "$modename: passing it literally to the linker, although it might fail" 1>&2
+	    abs_ladir="$ladir"
+	  fi
+	  ;;
+	esac
+	laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
+
+	# Find the relevant object directory and library name.
+	if test "X$installed" = Xyes; then
+	  if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
+	    $echo "$modename: warning: library \`$lib' was moved." 1>&2
+	    dir="$ladir"
+	    absdir="$abs_ladir"
+	    libdir="$abs_ladir"
+	  else
+	    dir="$libdir"
+	    absdir="$libdir"
+	  fi
+	else
+	  dir="$ladir/$objdir"
+	  absdir="$abs_ladir/$objdir"
+	  # Remove this search path later
+	  notinst_path="$notinst_path $abs_ladir"
+	fi # $installed = yes
+	name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
+
+	# This library was specified with -dlpreopen.
+	if test "$pass" = dlpreopen; then
+	  if test -z "$libdir"; then
+	    $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2
+	    exit 1
+	  fi
+	  # Prefer using a static library (so that no silly _DYNAMIC symbols
+	  # are required to link).
+	  if test -n "$old_library"; then
+	    newdlprefiles="$newdlprefiles $dir/$old_library"
+	  # Otherwise, use the dlname, so that lt_dlopen finds it.
+	  elif test -n "$dlname"; then
+	    newdlprefiles="$newdlprefiles $dir/$dlname"
+	  else
+	    newdlprefiles="$newdlprefiles $dir/$linklib"
+	  fi
+	fi # $pass = dlpreopen
+
+	if test -z "$libdir"; then
+	  # Link the convenience library
+	  if test "$linkmode" = lib; then
+	    deplibs="$dir/$old_library $deplibs"
+	  elif test "$linkmode,$pass" = "prog,link"; then
+	    compile_deplibs="$dir/$old_library $compile_deplibs"
+	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
+	  else
+	    deplibs="$lib $deplibs"
+	  fi
+	  continue
+	fi
+
+	if test "$linkmode" = prog && test "$pass" != link; then
+	  newlib_search_path="$newlib_search_path $ladir"
+	  deplibs="$lib $deplibs"
+
+	  linkalldeplibs=no
+	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
+	     test "$build_libtool_libs" = no; then
+	    linkalldeplibs=yes
+	  fi
+
+	  tmp_libs=
+	  for deplib in $dependency_libs; do
+	    case $deplib in
+	    -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test
+	    esac
+	    # Need to link against all dependency_libs?
+	    if test "$linkalldeplibs" = yes; then
+	      deplibs="$deplib $deplibs"
+	    else
+	      # Need to hardcode shared library paths
+	      # or/and link against static libraries
+	      newdependency_libs="$deplib $newdependency_libs"
+	    fi
+	    if test "X$duplicate_deps" = "Xyes" ; then
+	      case "$tmp_libs " in
+	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+	      esac
+	    fi
+	    tmp_libs="$tmp_libs $deplib"
+	  done # for deplib
+	  continue
+	fi # $linkmode = prog...
+
+	link_static=no # Whether the deplib will be linked statically
+	if test -n "$library_names" &&
+	   { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
+	  # Link against this shared library
+
+	  if test "$linkmode,$pass" = "prog,link" ||
+	   { test "$linkmode" = lib && test "$hardcode_into_libs" = yes; }; then
+	    # Hardcode the library path.
+	    # Skip directories that are in the system default run-time
+	    # search path.
+	    case " $sys_lib_dlsearch_path " in
+	    *" $absdir "*) ;;
+	    *)
+	      case "$compile_rpath " in
+	      *" $absdir "*) ;;
+	      *) compile_rpath="$compile_rpath $absdir"
+	      esac
+	      ;;
+	    esac
+	    case " $sys_lib_dlsearch_path " in
+	    *" $libdir "*) ;;
+	    *)
+	      case "$finalize_rpath " in
+	      *" $libdir "*) ;;
+	      *) finalize_rpath="$finalize_rpath $libdir"
+	      esac
+	      ;;
+	    esac
+	    if test "$linkmode" = prog; then
+	      # We need to hardcode the library path
+	      if test -n "$shlibpath_var"; then
+		# Make sure the rpath contains only unique directories.
+		case "$temp_rpath " in
+		*" $dir "*) ;;
+		*" $absdir "*) ;;
+		*) temp_rpath="$temp_rpath $dir" ;;
+		esac
+	      fi
+	    fi
+	  fi # $linkmode,$pass = prog,link...
+
+	  if test "$alldeplibs" = yes &&
+	     { test "$deplibs_check_method" = pass_all ||
+	       { test "$build_libtool_libs" = yes &&
+		 test -n "$library_names"; }; }; then
+	    # We only need to search for static libraries
+	    continue
+	  fi
+
+	  if test "$installed" = no; then
+	    notinst_deplibs="$notinst_deplibs $lib"
+	    need_relink=yes
+	  fi
+
+	  if test -n "$old_archive_from_expsyms_cmds"; then
+	    # figure out the soname
+	    set dummy $library_names
+	    realname="$2"
+	    shift; shift
+	    libname=`eval \\$echo \"$libname_spec\"`
+	    # use dlname if we got it. it's perfectly good, no?
+	    if test -n "$dlname"; then
+	      soname="$dlname"
+	    elif test -n "$soname_spec"; then
+	      # bleh windows
+	      case $host in
+	      *cygwin*)
+		major=`expr $current - $age`
+		versuffix="-$major"
+		;;
+	      esac
+	      eval soname=\"$soname_spec\"
+	    else
+	      soname="$realname"
+	    fi
+
+	    # Make a new name for the extract_expsyms_cmds to use
+	    soroot="$soname"
+	    soname=`echo $soroot | sed -e 's/^.*\///'`
+	    newlib="libimp-`echo $soname | sed 's/^lib//;s/\.dll$//'`.a"
+
+	    # If the library has no export list, then create one now
+	    if test -f "$output_objdir/$soname-def"; then :
+	    else
+	      $show "extracting exported symbol list from \`$soname'"
+	      save_ifs="$IFS"; IFS='~'
+	      eval cmds=\"$extract_expsyms_cmds\"
+	      for cmd in $cmds; do
+		IFS="$save_ifs"
+		$show "$cmd"
+		$run eval "$cmd" || exit $?
+	      done
+	      IFS="$save_ifs"
+	    fi
+
+	    # Create $newlib
+	    if test -f "$output_objdir/$newlib"; then :; else
+	      $show "generating import library for \`$soname'"
+	      save_ifs="$IFS"; IFS='~'
+	      eval cmds=\"$old_archive_from_expsyms_cmds\"
+	      for cmd in $cmds; do
+		IFS="$save_ifs"
+		$show "$cmd"
+		$run eval "$cmd" || exit $?
+	      done
+	      IFS="$save_ifs"
+	    fi
+	    # make sure the library variables are pointing to the new library
+	    dir=$output_objdir
+	    linklib=$newlib
+	  fi # test -n "$old_archive_from_expsyms_cmds"
+
+	  if test "$linkmode" = prog || test "$mode" != relink; then
+	    add_shlibpath=
+	    add_dir=
+	    add=
+	    lib_linked=yes
+	    case $hardcode_action in
+	    immediate | unsupported)
+	      if test "$hardcode_direct" = no; then
+		add="$dir/$linklib"
+	      elif test "$hardcode_minus_L" = no; then
+		case $host in
+		*-*-sunos*) add_shlibpath="$dir" ;;
+		esac
+		add_dir="-L$dir"
+		add="-l$name"
+	      elif test "$hardcode_shlibpath_var" = no; then
+		add_shlibpath="$dir"
+		add="-l$name"
+	      else
+		lib_linked=no
+	      fi
+	      ;;
+	    relink)
+	      if test "$hardcode_direct" = yes; then
+		add="$dir/$linklib"
+	      elif test "$hardcode_minus_L" = yes; then
+		add_dir="-L$dir"
+		add="-l$name"
+	      elif test "$hardcode_shlibpath_var" = yes; then
+		add_shlibpath="$dir"
+		add="-l$name"
+	      else
+		lib_linked=no
+	      fi
+	      ;;
+	    *) lib_linked=no ;;
+	    esac
+
+	    if test "$lib_linked" != yes; then
+	      $echo "$modename: configuration error: unsupported hardcode properties"
+	      exit 1
+	    fi
+
+	    if test -n "$add_shlibpath"; then
+	      case :$compile_shlibpath: in
+	      *":$add_shlibpath:"*) ;;
+	      *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
+	      esac
+	    fi
+	    if test "$linkmode" = prog; then
+	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
+	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
+	    else
+	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
+	      test -n "$add" && deplibs="$add $deplibs"
+	      if test "$hardcode_direct" != yes && \
+		 test "$hardcode_minus_L" != yes && \
+		 test "$hardcode_shlibpath_var" = yes; then
+		case :$finalize_shlibpath: in
+		*":$libdir:"*) ;;
+		*) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
+		esac
+	      fi
+	    fi
+	  fi
+
+	  if test "$linkmode" = prog || test "$mode" = relink; then
+	    add_shlibpath=
+	    add_dir=
+	    add=
+	    # Finalize command for both is simple: just hardcode it.
+	    if test "$hardcode_direct" = yes; then
+	      add="$libdir/$linklib"
+	    elif test "$hardcode_minus_L" = yes; then
+	      # Try looking first in the location we're being installed to.
+	      add_dir=
+	      if test -n "$inst_prefix_dir"; then
+		case "$libdir" in
+		[\\/]*)
+		  add_dir="-L$inst_prefix_dir$libdir"
+		  ;;
+		esac
+	      fi
+	      add_dir="$add_dir -L$libdir"
+	      add="-l$name"
+	    elif test "$hardcode_shlibpath_var" = yes; then
+	      case :$finalize_shlibpath: in
+	      *":$libdir:"*) ;;
+	      *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
+	      esac
+	      add="-l$name"
+	    else
+	      # We cannot seem to hardcode it, guess we'll fake it.
+	      # Try looking first in the location we're being installed to.
+	      add_dir=
+	      if test -n "$inst_prefix_dir"; then
+		case "$libdir" in
+		[\\/]*)
+		  add_dir="-L$inst_prefix_dir$libdir"
+		  ;;
+		esac
+	      fi
+	      add_dir="$add_dir -L$libdir"
+	      add="-l$name"
+	    fi
+
+	    if test "$linkmode" = prog; then
+	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
+	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
+	    else
+	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
+	      test -n "$add" && deplibs="$add $deplibs"
+	    fi
+	  fi
+	elif test "$linkmode" = prog; then
+	  if test "$alldeplibs" = yes &&
+	     { test "$deplibs_check_method" = pass_all ||
+	       { test "$build_libtool_libs" = yes &&
+		 test -n "$library_names"; }; }; then
+	    # We only need to search for static libraries
+	    continue
+	  fi
+
+	  # Try to link the static library
+	  # Here we assume that one of hardcode_direct or hardcode_minus_L
+	  # is not unsupported.  This is valid on all known static and
+	  # shared platforms.
+	  if test "$hardcode_direct" != unsupported; then
+	    test -n "$old_library" && linklib="$old_library"
+	    compile_deplibs="$dir/$linklib $compile_deplibs"
+	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
+	  else
+	    compile_deplibs="-l$name -L$dir $compile_deplibs"
+	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
+	  fi
+	elif test "$build_libtool_libs" = yes; then
+	  # Not a shared library
+	  if test "$deplibs_check_method" != pass_all; then
+	    # We're trying link a shared library against a static one
+	    # but the system doesn't support it.
+
+	    # Just print a warning and add the library to dependency_libs so
+	    # that the program can be linked against the static library.
+	    echo
+	    echo "*** Warning: This library needs some functionality provided by $lib."
+	    echo "*** I have the capability to make that library automatically link in when"
+	    echo "*** you link to this library.  But I can only do this if you have a"
+	    echo "*** shared version of the library, which you do not appear to have."
+	    if test "$module" = yes; then
+	      echo "*** Therefore, libtool will create a static module, that should work "
+	      echo "*** as long as the dlopening application is linked with the -dlopen flag."
+	      if test -z "$global_symbol_pipe"; then
+		echo
+		echo "*** However, this would only work if libtool was able to extract symbol"
+		echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
+		echo "*** not find such a program.  So, this module is probably useless."
+		echo "*** \`nm' from GNU binutils and a full rebuild may help."
+	      fi
+	      if test "$build_old_libs" = no; then
+		build_libtool_libs=module
+		build_old_libs=yes
+	      else
+		build_libtool_libs=no
+	      fi
+	    fi
+	  else
+	    convenience="$convenience $dir/$old_library"
+	    old_convenience="$old_convenience $dir/$old_library"
+	    deplibs="$dir/$old_library $deplibs"
+	    link_static=yes
+	  fi
+	fi # link shared/static library?
+
+	if test "$linkmode" = lib; then
+	  if test -n "$dependency_libs" &&
+	     { test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes ||
+	       test "$link_static" = yes; }; then
+	    # Extract -R from dependency_libs
+	    temp_deplibs=
+	    for libdir in $dependency_libs; do
+	      case $libdir in
+	      -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'`
+		   case " $xrpath " in
+		   *" $temp_xrpath "*) ;;
+		   *) xrpath="$xrpath $temp_xrpath";;
+		   esac;;
+	      *) temp_deplibs="$temp_deplibs $libdir";;
+	      esac
+	    done
+	    dependency_libs="$temp_deplibs"
+	  fi
+
+	  newlib_search_path="$newlib_search_path $absdir"
+	  # Link against this library
+	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
+	  # ... and its dependency_libs
+	  tmp_libs=
+	  for deplib in $dependency_libs; do
+	    newdependency_libs="$deplib $newdependency_libs"
+	    if test "X$duplicate_deps" = "Xyes" ; then
+	      case "$tmp_libs " in
+	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+	      esac
+	    fi
+	    tmp_libs="$tmp_libs $deplib"
+	  done
+
+	  if test "$link_all_deplibs" != no; then
+	    # Add the search paths of all dependency libraries
+	    for deplib in $dependency_libs; do
+	      case $deplib in
+	      -L*) path="$deplib" ;;
+	      *.la)
+		dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'`
+		test "X$dir" = "X$deplib" && dir="."
+		# We need an absolute path.
+		case $dir in
+		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
+		*)
+		  absdir=`cd "$dir" && pwd`
+		  if test -z "$absdir"; then
+		    $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2
+		    absdir="$dir"
+		  fi
+		  ;;
+		esac
+		if grep "^installed=no" $deplib > /dev/null; then
+		  path="-L$absdir/$objdir"
+		else
+		  eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
+		  if test -z "$libdir"; then
+		    $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
+		    exit 1
+		  fi
+		  if test "$absdir" != "$libdir"; then
+		    $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2
+		  fi
+		  path="-L$absdir"
+		fi
+		;;
+	      *) continue ;;
+	      esac
+	      case " $deplibs " in
+	      *" $path "*) ;;
+	      *) deplibs="$deplibs $path" ;;
+	      esac
+	    done
+	  fi # link_all_deplibs != no
+	fi # linkmode = lib
+      done # for deplib in $libs
+      if test "$pass" = dlpreopen; then
+	# Link the dlpreopened libraries before other libraries
+	for deplib in $save_deplibs; do
+	  deplibs="$deplib $deplibs"
+	done
+      fi
+      if test "$pass" != dlopen; then
+	test "$pass" != scan && dependency_libs="$newdependency_libs"
+	if test "$pass" != conv; then
+	  # Make sure lib_search_path contains only unique directories.
+	  lib_search_path=
+	  for dir in $newlib_search_path; do
+	    case "$lib_search_path " in
+	    *" $dir "*) ;;
+	    *) lib_search_path="$lib_search_path $dir" ;;
+	    esac
+	  done
+	  newlib_search_path=
+	fi
+
+	if test "$linkmode,$pass" != "prog,link"; then
+	  vars="deplibs"
+	else
+	  vars="compile_deplibs finalize_deplibs"
+	fi
+	for var in $vars dependency_libs; do
+	  # Add libraries to $var in reverse order
+	  eval tmp_libs=\"\$$var\"
+	  new_libs=
+	  for deplib in $tmp_libs; do
+	    case $deplib in
+	    -L*) new_libs="$deplib $new_libs" ;;
+	    *)
+	      case " $specialdeplibs " in
+	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
+	      *)
+		case " $new_libs " in
+		*" $deplib "*) ;;
+		*) new_libs="$deplib $new_libs" ;;
+		esac
+		;;
+	      esac
+	      ;;
+	    esac
+	  done
+	  tmp_libs=
+	  for deplib in $new_libs; do
+	    case $deplib in
+	    -L*)
+	      case " $tmp_libs " in
+	      *" $deplib "*) ;;
+	      *) tmp_libs="$tmp_libs $deplib" ;;
+	      esac
+	      ;;
+	    *) tmp_libs="$tmp_libs $deplib" ;;
+	    esac
+	  done
+	  eval $var=\"$tmp_libs\"
+	done # for var
+      fi
+      if test "$pass" = "conv" &&
+       { test "$linkmode" = "lib" || test "$linkmode" = "prog"; }; then
+	libs="$deplibs" # reset libs
+	deplibs=
+      fi
+    done # for pass
+    if test "$linkmode" = prog; then
+      dlfiles="$newdlfiles"
+      dlprefiles="$newdlprefiles"
+    fi
+
+    case $linkmode in
+    oldlib)
+      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+	$echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2
+      fi
+
+      if test -n "$rpath"; then
+	$echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2
+      fi
+
+      if test -n "$xrpath"; then
+	$echo "$modename: warning: \`-R' is ignored for archives" 1>&2
+      fi
+
+      if test -n "$vinfo"; then
+	$echo "$modename: warning: \`-version-info' is ignored for archives" 1>&2
+      fi
+
+      if test -n "$release"; then
+	$echo "$modename: warning: \`-release' is ignored for archives" 1>&2
+      fi
+
+      if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
+	$echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2
+      fi
+
+      # Now set the variables for building old libraries.
+      build_libtool_libs=no
+      oldlibs="$output"
+      objs="$objs$old_deplibs"
+      ;;
+
+    lib)
+      # Make sure we only generate libraries of the form `libNAME.la'.
+      case $outputname in
+      lib*)
+	name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
+	eval libname=\"$libname_spec\"
+	;;
+      *)
+	if test "$module" = no; then
+	  $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2
+	  $echo "$help" 1>&2
+	  exit 1
+	fi
+	if test "$need_lib_prefix" != no; then
+	  # Add the "lib" prefix for modules if required
+	  name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
+	  eval libname=\"$libname_spec\"
+	else
+	  libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
+	fi
+	;;
+      esac
+
+      if test -n "$objs"; then
+	if test "$deplibs_check_method" != pass_all; then
+	  $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1
+	  exit 1
+	else
+	  echo
+	  echo "*** Warning: Linking the shared library $output against the non-libtool"
+	  echo "*** objects $objs is not portable!"
+	  libobjs="$libobjs $objs"
+	fi
+      fi
+
+      if test "$dlself" != no; then
+	$echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2
+      fi
+
+      set dummy $rpath
+      if test "$#" -gt 2; then
+	$echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2
+      fi
+      install_libdir="$2"
+
+      oldlibs=
+      if test -z "$rpath"; then
+	if test "$build_libtool_libs" = yes; then
+	  # Building a libtool convenience library.
+	  libext=al
+	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
+	  build_libtool_libs=convenience
+	  build_old_libs=yes
+	fi
+
+	if test -n "$vinfo"; then
+	  $echo "$modename: warning: \`-version-info' is ignored for convenience libraries" 1>&2
+	fi
+
+	if test -n "$release"; then
+	  $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2
+	fi
+      else
+
+	# Parse the version information argument.
+	save_ifs="$IFS"; IFS=':'
+	set dummy $vinfo 0 0 0
+	IFS="$save_ifs"
+
+	if test -n "$8"; then
+	  $echo "$modename: too many parameters to \`-version-info'" 1>&2
+	  $echo "$help" 1>&2
+	  exit 1
+	fi
+
+	current="$2"
+	revision="$3"
+	age="$4"
+
+	# Check that each of the things are valid numbers.
+	case $current in
+	[0-9]*) ;;
+	*)
+	  $echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2
+	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
+	  exit 1
+	  ;;
+	esac
+
+	case $revision in
+	[0-9]*) ;;
+	*)
+	  $echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2
+	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
+	  exit 1
+	  ;;
+	esac
+
+	case $age in
+	[0-9]*) ;;
+	*)
+	  $echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2
+	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
+	  exit 1
+	  ;;
+	esac
+
+	if test "$age" -gt "$current"; then
+	  $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2
+	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
+	  exit 1
+	fi
+
+	# Calculate the version variables.
+	major=
+	versuffix=
+	verstring=
+	case $version_type in
+	none) ;;
+
+	darwin)
+	  # Like Linux, but with the current version available in
+	  # verstring for coding it into the library header
+	  major=.`expr $current - $age`
+	  versuffix="$major.$age.$revision"
+	  # Darwin ld doesn't like 0 for these options...
+	  minor_current=`expr $current + 1`
+	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
+	  ;;
+
+	freebsd-aout)
+	  major=".$current"
+	  versuffix=".$current.$revision";
+	  ;;
+
+	freebsd-elf)
+	  major=".$current"
+	  versuffix=".$current";
+	  ;;
+
+	irix)
+	  major=`expr $current - $age + 1`
+	  verstring="sgi$major.$revision"
+
+	  # Add in all the interfaces that we are compatible with.
+	  loop=$revision
+	  while test "$loop" -ne 0; do
+	    iface=`expr $revision - $loop`
+	    loop=`expr $loop - 1`
+	    verstring="sgi$major.$iface:$verstring"
+	  done
+
+	  # Before this point, $major must not contain `.'.
+	  major=.$major
+	  versuffix="$major.$revision"
+	  ;;
+
+	linux)
+	  major=.`expr $current - $age`
+	  versuffix="$major.$age.$revision"
+	  ;;
+
+	osf)
+	  major=`expr $current - $age`
+	  versuffix=".$current.$age.$revision"
+	  verstring="$current.$age.$revision"
+
+	  # Add in all the interfaces that we are compatible with.
+	  loop=$age
+	  while test "$loop" -ne 0; do
+	    iface=`expr $current - $loop`
+	    loop=`expr $loop - 1`
+	    verstring="$verstring:${iface}.0"
+	  done
+
+	  # Make executables depend on our current version.
+	  verstring="$verstring:${current}.0"
+	  ;;
+
+	sunos)
+	  major=".$current"
+	  versuffix=".$current.$revision"
+	  ;;
+
+	windows)
+	  # Use '-' rather than '.', since we only want one
+	  # extension on DOS 8.3 filesystems.
+	  major=`expr $current - $age`
+	  versuffix="-$major"
+	  ;;
+
+	*)
+	  $echo "$modename: unknown library version type \`$version_type'" 1>&2
+	  echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
+	  exit 1
+	  ;;
+	esac
+
+	# Clear the version info if we defaulted, and they specified a release.
+	if test -z "$vinfo" && test -n "$release"; then
+	  major=
+	  verstring="0.0"
+	  case $version_type in
+	  darwin)
+	    # we can't check for "0.0" in archive_cmds due to quoting
+	    # problems, so we reset it completely
+	    verstring=""
+	    ;;
+	  *)
+	    verstring="0.0"
+	    ;;
+	  esac
+	  if test "$need_version" = no; then
+	    versuffix=
+	  else
+	    versuffix=".0.0"
+	  fi
+	fi
+
+	# Remove version info from name if versioning should be avoided
+	if test "$avoid_version" = yes && test "$need_version" = no; then
+	  major=
+	  versuffix=
+	  verstring=""
+	fi
+
+	# Check to see if the archive will have undefined symbols.
+	if test "$allow_undefined" = yes; then
+	  if test "$allow_undefined_flag" = unsupported; then
+	    $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2
+	    build_libtool_libs=no
+	    build_old_libs=yes
+	  fi
+	else
+	  # Don't allow undefined symbols.
+	  allow_undefined_flag="$no_undefined_flag"
+	fi
+      fi
+
+      if test "$mode" != relink; then
+	# Remove our outputs.
+	$show "${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.*"
+	$run ${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.*
+      fi
+
+      # Now set the variables for building old libraries.
+      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
+	oldlibs="$oldlibs $output_objdir/$libname.$libext"
+
+	# Transform .lo files to .o files.
+	oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
+      fi
+
+      # Eliminate all temporary directories.
+      for path in $notinst_path; do
+	lib_search_path=`echo "$lib_search_path " | sed -e 's% $path % %g'`
+	deplibs=`echo "$deplibs " | sed -e 's% -L$path % %g'`
+	dependency_libs=`echo "$dependency_libs " | sed -e 's% -L$path % %g'`
+      done
+
+      if test -n "$xrpath"; then
+	# If the user specified any rpath flags, then add them.
+	temp_xrpath=
+	for libdir in $xrpath; do
+	  temp_xrpath="$temp_xrpath -R$libdir"
+	  case "$finalize_rpath " in
+	  *" $libdir "*) ;;
+	  *) finalize_rpath="$finalize_rpath $libdir" ;;
+	  esac
+	done
+	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
+	  dependency_libs="$temp_xrpath $dependency_libs"
+	fi
+      fi
+
+      # Make sure dlfiles contains only unique files that won't be dlpreopened
+      old_dlfiles="$dlfiles"
+      dlfiles=
+      for lib in $old_dlfiles; do
+	case " $dlprefiles $dlfiles " in
+	*" $lib "*) ;;
+	*) dlfiles="$dlfiles $lib" ;;
+	esac
+      done
+
+      # Make sure dlprefiles contains only unique files
+      old_dlprefiles="$dlprefiles"
+      dlprefiles=
+      for lib in $old_dlprefiles; do
+	case "$dlprefiles " in
+	*" $lib "*) ;;
+	*) dlprefiles="$dlprefiles $lib" ;;
+	esac
+      done
+
+      if test "$build_libtool_libs" = yes; then
+	if test -n "$rpath"; then
+	  case $host in
+	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*)
+	    # these systems don't actually have a c library (as such)!
+	    ;;
+	  *-*-rhapsody* | *-*-darwin1.[012])
+	    # Rhapsody C library is in the System framework
+	    deplibs="$deplibs -framework System"
+	    ;;
+	  *-*-netbsd*)
+	    # Don't link with libc until the a.out ld.so is fixed.
+	    ;;
+	  *-*-openbsd*)
+	    # Do not include libc due to us having libc/libc_r.
+	    ;;
+	  *)
+	    # Add libc to deplibs on all other systems if necessary.
+	    if test "$build_libtool_need_lc" = "yes"; then
+	      deplibs="$deplibs -lc"
+	    fi
+	    ;;
+	  esac
+	fi
+
+	# Transform deplibs into only deplibs that can be linked in shared.
+	name_save=$name
+	libname_save=$libname
+	release_save=$release
+	versuffix_save=$versuffix
+	major_save=$major
+	# I'm not sure if I'm treating the release correctly.  I think
+	# release should show up in the -l (ie -lgmp5) so we don't want to
+	# add it in twice.  Is that correct?
+	release=""
+	versuffix=""
+	major=""
+	newdeplibs=
+	droppeddeps=no
+	case $deplibs_check_method in
+	pass_all)
+	  # Don't check for shared/static.  Everything works.
+	  # This might be a little naive.  We might want to check
+	  # whether the library exists or not.  But this is on
+	  # osf3 & osf4 and I'm not really sure... Just
+	  # implementing what was already the behaviour.
+	  newdeplibs=$deplibs
+	  ;;
+	test_compile)
+	  # This code stresses the "libraries are programs" paradigm to its
+	  # limits. Maybe even breaks it.  We compile a program, linking it
+	  # against the deplibs as a proxy for the library.  Then we can check
+	  # whether they linked in statically or dynamically with ldd.
+	  $rm conftest.c
+	  cat > conftest.c <<EOF
+	  int main() { return 0; }
+EOF
+	  $rm conftest
+	  $CC -o conftest conftest.c $deplibs
+	  if test "$?" -eq 0 ; then
+	    ldd_output=`ldd conftest`
+	    for i in $deplibs; do
+	      name="`expr $i : '-l\(.*\)'`"
+	      # If $name is empty we are operating on a -L argument.
+	      if test -n "$name" && test "$name" != "0"; then
+		libname=`eval \\$echo \"$libname_spec\"`
+		deplib_matches=`eval \\$echo \"$library_names_spec\"`
+		set dummy $deplib_matches
+		deplib_match=$2
+		if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+		  newdeplibs="$newdeplibs $i"
+		else
+		  droppeddeps=yes
+		  echo
+		  echo "*** Warning: This library needs some functionality provided by $i."
+		  echo "*** I have the capability to make that library automatically link in when"
+		  echo "*** you link to this library.  But I can only do this if you have a"
+		  echo "*** shared version of the library, which you do not appear to have."
+		fi
+	      else
+		newdeplibs="$newdeplibs $i"
+	      fi
+	    done
+	  else
+	    # Error occured in the first compile.  Let's try to salvage the situation:
+	    # Compile a seperate program for each library.
+	    for i in $deplibs; do
+	      name="`expr $i : '-l\(.*\)'`"
+	     # If $name is empty we are operating on a -L argument.
+	      if test -n "$name" && test "$name" != "0"; then
+		$rm conftest
+		$CC -o conftest conftest.c $i
+		# Did it work?
+		if test "$?" -eq 0 ; then
+		  ldd_output=`ldd conftest`
+		  libname=`eval \\$echo \"$libname_spec\"`
+		  deplib_matches=`eval \\$echo \"$library_names_spec\"`
+		  set dummy $deplib_matches
+		  deplib_match=$2
+		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+		    newdeplibs="$newdeplibs $i"
+		  else
+		    droppeddeps=yes
+		    echo
+		    echo "*** Warning: This library needs some functionality provided by $i."
+		    echo "*** I have the capability to make that library automatically link in when"
+		    echo "*** you link to this library.  But I can only do this if you have a"
+		    echo "*** shared version of the library, which you do not appear to have."
+		  fi
+		else
+		  droppeddeps=yes
+		  echo
+		  echo "*** Warning!  Library $i is needed by this library but I was not able to"
+		  echo "***  make it link in!  You will probably need to install it or some"
+		  echo "*** library that it depends on before this library will be fully"
+		  echo "*** functional.  Installing it before continuing would be even better."
+		fi
+	      else
+		newdeplibs="$newdeplibs $i"
+	      fi
+	    done
+	  fi
+	  ;;
+	file_magic*)
+	  set dummy $deplibs_check_method
+	  file_magic_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
+	  for a_deplib in $deplibs; do
+	    name="`expr $a_deplib : '-l\(.*\)'`"
+	    # If $name is empty we are operating on a -L argument.
+	    if test -n "$name" && test "$name" != "0"; then
+	      libname=`eval \\$echo \"$libname_spec\"`
+	      for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
+		    potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
+		    for potent_lib in $potential_libs; do
+		      # Follow soft links.
+		      if ls -lLd "$potent_lib" 2>/dev/null \
+			 | grep " -> " >/dev/null; then
+			continue
+		      fi
+		      # The statement above tries to avoid entering an
+		      # endless loop below, in case of cyclic links.
+		      # We might still enter an endless loop, since a link
+		      # loop can be closed while we follow links,
+		      # but so what?
+		      potlib="$potent_lib"
+		      while test -h "$potlib" 2>/dev/null; do
+			potliblink=`ls -ld $potlib | sed 's/.* -> //'`
+			case $potliblink in
+			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
+			*) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
+			esac
+		      done
+		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \
+			 | sed 10q \
+			 | egrep "$file_magic_regex" > /dev/null; then
+			newdeplibs="$newdeplibs $a_deplib"
+			a_deplib=""
+			break 2
+		      fi
+		    done
+	      done
+	      if test -n "$a_deplib" ; then
+		droppeddeps=yes
+		echo
+		echo "*** Warning: This library needs some functionality provided by $a_deplib."
+		echo "*** I have the capability to make that library automatically link in when"
+		echo "*** you link to this library.  But I can only do this if you have a"
+		echo "*** shared version of the library, which you do not appear to have."
+	      fi
+	    else
+	      # Add a -L argument.
+	      newdeplibs="$newdeplibs $a_deplib"
+	    fi
+	  done # Gone through all deplibs.
+	  ;;
+	match_pattern*)
+	  set dummy $deplibs_check_method
+	  match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
+	  for a_deplib in $deplibs; do
+	    name="`expr $a_deplib : '-l\(.*\)'`"
+	    # If $name is empty we are operating on a -L argument.
+	    if test -n "$name" && test "$name" != "0"; then
+	      libname=`eval \\$echo \"$libname_spec\"`
+	      for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
+		potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
+		for potent_lib in $potential_libs; do
+		  if eval echo \"$potent_lib\" 2>/dev/null \
+		      | sed 10q \
+		      | egrep "$match_pattern_regex" > /dev/null; then
+		    newdeplibs="$newdeplibs $a_deplib"
+		    a_deplib=""
+		    break 2
+		  fi
+		done
+	      done
+	      if test -n "$a_deplib" ; then
+		droppeddeps=yes
+		echo
+		echo "*** Warning: This library needs some functionality provided by $a_deplib."
+		echo "*** I have the capability to make that library automatically link in when"
+		echo "*** you link to this library.  But I can only do this if you have a"
+		echo "*** shared version of the library, which you do not appear to have."
+	      fi
+	    else
+	      # Add a -L argument.
+	      newdeplibs="$newdeplibs $a_deplib"
+	    fi
+	  done # Gone through all deplibs.
+	  ;;
+	none | unknown | *)
+	  newdeplibs=""
+	  if $echo "X $deplibs" | $Xsed -e 's/ -lc$//' \
+	       -e 's/ -[LR][^ ]*//g' -e 's/[ 	]//g' |
+	     grep . >/dev/null; then
+	    echo
+	    if test "X$deplibs_check_method" = "Xnone"; then
+	      echo "*** Warning: inter-library dependencies are not supported in this platform."
+	    else
+	      echo "*** Warning: inter-library dependencies are not known to be supported."
+	    fi
+	    echo "*** All declared inter-library dependencies are being dropped."
+	    droppeddeps=yes
+	  fi
+	  ;;
+	esac
+	versuffix=$versuffix_save
+	major=$major_save
+	release=$release_save
+	libname=$libname_save
+	name=$name_save
+
+	case $host in
+	*-*-rhapsody* | *-*-darwin1.[012])
+	  # On Rhapsody replace the C library is the System framework
+	  newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'`
+	  ;;
+	esac
+
+	if test "$droppeddeps" = yes; then
+	  if test "$module" = yes; then
+	    echo
+	    echo "*** Warning: libtool could not satisfy all declared inter-library"
+	    echo "*** dependencies of module $libname.  Therefore, libtool will create"
+	    echo "*** a static module, that should work as long as the dlopening"
+	    echo "*** application is linked with the -dlopen flag."
+	    if test -z "$global_symbol_pipe"; then
+	      echo
+	      echo "*** However, this would only work if libtool was able to extract symbol"
+	      echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
+	      echo "*** not find such a program.  So, this module is probably useless."
+	      echo "*** \`nm' from GNU binutils and a full rebuild may help."
+	    fi
+	    if test "$build_old_libs" = no; then
+	      oldlibs="$output_objdir/$libname.$libext"
+	      build_libtool_libs=module
+	      build_old_libs=yes
+	    else
+	      build_libtool_libs=no
+	    fi
+	  else
+	    echo "*** The inter-library dependencies that have been dropped here will be"
+	    echo "*** automatically added whenever a program is linked with this library"
+	    echo "*** or is declared to -dlopen it."
+
+	    if test "$allow_undefined" = no; then
+	      echo
+	      echo "*** Since this library must not contain undefined symbols,"
+	      echo "*** because either the platform does not support them or"
+	      echo "*** it was explicitly requested with -no-undefined,"
+	      echo "*** libtool will only create a static version of it."
+	      if test "$build_old_libs" = no; then
+		oldlibs="$output_objdir/$libname.$libext"
+		build_libtool_libs=module
+		build_old_libs=yes
+	      else
+		build_libtool_libs=no
+	      fi
+	    fi
+	  fi
+	fi
+	# Done checking deplibs!
+	deplibs=$newdeplibs
+      fi
+
+      # All the library-specific variables (install_libdir is set above).
+      library_names=
+      old_library=
+      dlname=
+
+      # Test again, we may have decided not to build it any more
+      if test "$build_libtool_libs" = yes; then
+	if test "$hardcode_into_libs" = yes; then
+	  # Hardcode the library paths
+	  hardcode_libdirs=
+	  dep_rpath=
+	  rpath="$finalize_rpath"
+	  test "$mode" != relink && rpath="$compile_rpath$rpath"
+	  for libdir in $rpath; do
+	    if test -n "$hardcode_libdir_flag_spec"; then
+	      if test -n "$hardcode_libdir_separator"; then
+		if test -z "$hardcode_libdirs"; then
+		  hardcode_libdirs="$libdir"
+		else
+		  # Just accumulate the unique libdirs.
+		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+		    ;;
+		  *)
+		    hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+		    ;;
+		  esac
+		fi
+	      else
+		eval flag=\"$hardcode_libdir_flag_spec\"
+		dep_rpath="$dep_rpath $flag"
+	      fi
+	    elif test -n "$runpath_var"; then
+	      case "$perm_rpath " in
+	      *" $libdir "*) ;;
+	      *) perm_rpath="$perm_rpath $libdir" ;;
+	      esac
+	    fi
+	  done
+	  # Substitute the hardcoded libdirs into the rpath.
+	  if test -n "$hardcode_libdir_separator" &&
+	     test -n "$hardcode_libdirs"; then
+	    libdir="$hardcode_libdirs"
+	    eval dep_rpath=\"$hardcode_libdir_flag_spec\"
+	  fi
+	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
+	    # We should set the runpath_var.
+	    rpath=
+	    for dir in $perm_rpath; do
+	      rpath="$rpath$dir:"
+	    done
+	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
+	  fi
+	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
+	fi
+
+	shlibpath="$finalize_shlibpath"
+	test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
+	if test -n "$shlibpath"; then
+	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
+	fi
+
+	# Get the real and link names of the library.
+	eval library_names=\"$library_names_spec\"
+	set dummy $library_names
+	realname="$2"
+	shift; shift
+
+	if test -n "$soname_spec"; then
+	  eval soname=\"$soname_spec\"
+	else
+	  soname="$realname"
+	fi
+	test -z "$dlname" && dlname=$soname
+
+	lib="$output_objdir/$realname"
+	for link
+	do
+	  linknames="$linknames $link"
+	done
+
+	# Ensure that we have .o objects for linkers which dislike .lo
+	# (e.g. aix) in case we are running --disable-static
+	for obj in $libobjs; do
+	  xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
+	  if test "X$xdir" = "X$obj"; then
+	    xdir="."
+	  else
+	    xdir="$xdir"
+	  fi
+	  baseobj=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
+	  oldobj=`$echo "X$baseobj" | $Xsed -e "$lo2o"`
+	  if test ! -f $xdir/$oldobj; then
+	    $show "(cd $xdir && ${LN_S} $baseobj $oldobj)"
+	    $run eval '(cd $xdir && ${LN_S} $baseobj $oldobj)' || exit $?
+	  fi
+	done
+
+	# Use standard objects if they are pic
+	test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+
+	# Prepare the list of exported symbols
+	if test -z "$export_symbols"; then
+	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
+	    $show "generating symbol list for \`$libname.la'"
+	    export_symbols="$output_objdir/$libname.exp"
+	    $run $rm $export_symbols
+	    eval cmds=\"$export_symbols_cmds\"
+	    save_ifs="$IFS"; IFS='~'
+	    for cmd in $cmds; do
+	      IFS="$save_ifs"
+	      $show "$cmd"
+	      $run eval "$cmd" || exit $?
+	    done
+	    IFS="$save_ifs"
+	    if test -n "$export_symbols_regex"; then
+	      $show "egrep -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\""
+	      $run eval 'egrep -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
+	      $show "$mv \"${export_symbols}T\" \"$export_symbols\""
+	      $run eval '$mv "${export_symbols}T" "$export_symbols"'
+	    fi
+	  fi
+	fi
+
+	if test -n "$export_symbols" && test -n "$include_expsyms"; then
+	  $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"'
+	fi
+
+	if test -n "$convenience"; then
+	  if test -n "$whole_archive_flag_spec"; then
+	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
+	  else
+	    gentop="$output_objdir/${outputname}x"
+	    $show "${rm}r $gentop"
+	    $run ${rm}r "$gentop"
+	    $show "mkdir $gentop"
+	    $run mkdir "$gentop"
+	    status=$?
+	    if test "$status" -ne 0 && test ! -d "$gentop"; then
+	      exit $status
+	    fi
+	    generated="$generated $gentop"
+
+	    for xlib in $convenience; do
+	      # Extract the objects.
+	      case $xlib in
+	      [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
+	      *) xabs=`pwd`"/$xlib" ;;
+	      esac
+	      xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
+	      xdir="$gentop/$xlib"
+
+	      $show "${rm}r $xdir"
+	      $run ${rm}r "$xdir"
+	      $show "mkdir $xdir"
+	      $run mkdir "$xdir"
+	      status=$?
+	      if test "$status" -ne 0 && test ! -d "$xdir"; then
+		exit $status
+	      fi
+	      $show "(cd $xdir && $AR x $xabs)"
+	      $run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
+
+	      libobjs="$libobjs "`find $xdir -name \*.o -print -o -name \*.lo -print | $NL2SP`
+	    done
+	  fi
+	fi
+
+	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
+	  eval flag=\"$thread_safe_flag_spec\"
+	  linker_flags="$linker_flags $flag"
+	fi
+
+	# Make a backup of the uninstalled library when relinking
+	if test "$mode" = relink; then
+	  $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $?
+	fi
+
+	# Do each of the archive commands.
+	if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
+	  eval cmds=\"$archive_expsym_cmds\"
+	else
+	  eval cmds=\"$archive_cmds\"
+	fi
+	save_ifs="$IFS"; IFS='~'
+	for cmd in $cmds; do
+	  IFS="$save_ifs"
+	  $show "$cmd"
+	  $run eval "$cmd" || exit $?
+	done
+	IFS="$save_ifs"
+
+	# Restore the uninstalled library and exit
+	if test "$mode" = relink; then
+	  $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $?
+	  exit 0
+	fi
+
+	# Create links to the real library.
+	for linkname in $linknames; do
+	  if test "$realname" != "$linkname"; then
+	    $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)"
+	    $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $?
+	  fi
+	done
+
+	# If -module or -export-dynamic was specified, set the dlname.
+	if test "$module" = yes || test "$export_dynamic" = yes; then
+	  # On all known operating systems, these are identical.
+	  dlname="$soname"
+	fi
+      fi
+      ;;
+
+    obj)
+      if test -n "$deplibs"; then
+	$echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2
+      fi
+
+      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+	$echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2
+      fi
+
+      if test -n "$rpath"; then
+	$echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2
+      fi
+
+      if test -n "$xrpath"; then
+	$echo "$modename: warning: \`-R' is ignored for objects" 1>&2
+      fi
+
+      if test -n "$vinfo"; then
+	$echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2
+      fi
+
+      if test -n "$release"; then
+	$echo "$modename: warning: \`-release' is ignored for objects" 1>&2
+      fi
+
+      case $output in
+      *.lo)
+	if test -n "$objs$old_deplibs"; then
+	  $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2
+	  exit 1
+	fi
+	libobj="$output"
+	obj=`$echo "X$output" | $Xsed -e "$lo2o"`
+	;;
+      *)
+	libobj=
+	obj="$output"
+	;;
+      esac
+
+      # Delete the old objects.
+      $run $rm $obj $libobj
+
+      # Objects from convenience libraries.  This assumes
+      # single-version convenience libraries.  Whenever we create
+      # different ones for PIC/non-PIC, this we'll have to duplicate
+      # the extraction.
+      reload_conv_objs=
+      gentop=
+      # reload_cmds runs $LD directly, so let us get rid of
+      # -Wl from whole_archive_flag_spec
+      wl=
+
+      if test -n "$convenience"; then
+	if test -n "$whole_archive_flag_spec"; then
+	  eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\"
+	else
+	  gentop="$output_objdir/${obj}x"
+	  $show "${rm}r $gentop"
+	  $run ${rm}r "$gentop"
+	  $show "mkdir $gentop"
+	  $run mkdir "$gentop"
+	  status=$?
+	  if test "$status" -ne 0 && test ! -d "$gentop"; then
+	    exit $status
+	  fi
+	  generated="$generated $gentop"
+
+	  for xlib in $convenience; do
+	    # Extract the objects.
+	    case $xlib in
+	    [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
+	    *) xabs=`pwd`"/$xlib" ;;
+	    esac
+	    xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
+	    xdir="$gentop/$xlib"
+
+	    $show "${rm}r $xdir"
+	    $run ${rm}r "$xdir"
+	    $show "mkdir $xdir"
+	    $run mkdir "$xdir"
+	    status=$?
+	    if test "$status" -ne 0 && test ! -d "$xdir"; then
+	      exit $status
+	    fi
+	    $show "(cd $xdir && $AR x $xabs)"
+	    $run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
+
+	    reload_conv_objs="$reload_objs "`find $xdir -name \*.o -print -o -name \*.lo -print | $NL2SP`
+	  done
+	fi
+      fi
+
+      # Create the old-style object.
+      reload_objs="$objs$old_deplibs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
+
+      output="$obj"
+      eval cmds=\"$reload_cmds\"
+      save_ifs="$IFS"; IFS='~'
+      for cmd in $cmds; do
+	IFS="$save_ifs"
+	$show "$cmd"
+	$run eval "$cmd" || exit $?
+      done
+      IFS="$save_ifs"
+
+      # Exit if we aren't doing a library object file.
+      if test -z "$libobj"; then
+	if test -n "$gentop"; then
+	  $show "${rm}r $gentop"
+	  $run ${rm}r $gentop
+	fi
+
+	exit 0
+      fi
+
+      if test "$build_libtool_libs" != yes; then
+	if test -n "$gentop"; then
+	  $show "${rm}r $gentop"
+	  $run ${rm}r $gentop
+	fi
+
+	# Create an invalid libtool object if no PIC, so that we don't
+	# accidentally link it into a program.
+	$show "echo timestamp > $libobj"
+	$run eval "echo timestamp > $libobj" || exit $?
+	exit 0
+      fi
+
+      if test -n "$pic_flag" || test "$pic_mode" != default; then
+	# Only do commands if we really have different PIC objects.
+	reload_objs="$libobjs $reload_conv_objs"
+	output="$libobj"
+	eval cmds=\"$reload_cmds\"
+	save_ifs="$IFS"; IFS='~'
+	for cmd in $cmds; do
+	  IFS="$save_ifs"
+	  $show "$cmd"
+	  $run eval "$cmd" || exit $?
+	done
+	IFS="$save_ifs"
+      else
+	# Just create a symlink.
+	$show $rm $libobj
+	$run $rm $libobj
+	xdir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'`
+	if test "X$xdir" = "X$libobj"; then
+	  xdir="."
+	else
+	  xdir="$xdir"
+	fi
+	baseobj=`$echo "X$libobj" | $Xsed -e 's%^.*/%%'`
+	oldobj=`$echo "X$baseobj" | $Xsed -e "$lo2o"`
+	$show "(cd $xdir && $LN_S $oldobj $baseobj)"
+	$run eval '(cd $xdir && $LN_S $oldobj $baseobj)' || exit $?
+      fi
+
+      if test -n "$gentop"; then
+	$show "${rm}r $gentop"
+	$run ${rm}r $gentop
+      fi
+
+      exit 0
+      ;;
+
+    prog)
+      case $host in
+	*cygwin*) output=`echo $output | sed -e 's,.exe$,,;s,$,.exe,'` ;;
+      esac
+      if test -n "$vinfo"; then
+	$echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2
+      fi
+
+      if test -n "$release"; then
+	$echo "$modename: warning: \`-release' is ignored for programs" 1>&2
+      fi
+
+      if test "$preload" = yes; then
+	if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown &&
+	   test "$dlopen_self_static" = unknown; then
+	  $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support."
+	fi
+      fi
+
+      case $host in
+      *-*-rhapsody* | *-*-darwin1.[012])
+	# On Rhapsody replace the C library is the System framework
+	compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
+	finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
+	;;
+      esac
+
+      compile_command="$compile_command $compile_deplibs"
+      finalize_command="$finalize_command $finalize_deplibs"
+
+      if test -n "$rpath$xrpath"; then
+	# If the user specified any rpath flags, then add them.
+	for libdir in $rpath $xrpath; do
+	  # This is the magic to use -rpath.
+	  case "$finalize_rpath " in
+	  *" $libdir "*) ;;
+	  *) finalize_rpath="$finalize_rpath $libdir" ;;
+	  esac
+	done
+      fi
+
+      # Now hardcode the library paths
+      rpath=
+      hardcode_libdirs=
+      for libdir in $compile_rpath $finalize_rpath; do
+	if test -n "$hardcode_libdir_flag_spec"; then
+	  if test -n "$hardcode_libdir_separator"; then
+	    if test -z "$hardcode_libdirs"; then
+	      hardcode_libdirs="$libdir"
+	    else
+	      # Just accumulate the unique libdirs.
+	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+		;;
+	      *)
+		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+		;;
+	      esac
+	    fi
+	  else
+	    eval flag=\"$hardcode_libdir_flag_spec\"
+	    rpath="$rpath $flag"
+	  fi
+	elif test -n "$runpath_var"; then
+	  case "$perm_rpath " in
+	  *" $libdir "*) ;;
+	  *) perm_rpath="$perm_rpath $libdir" ;;
+	  esac
+	fi
+	case $host in
+	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
+	  case :$dllsearchpath: in
+	  *":$libdir:"*) ;;
+	  *) dllsearchpath="$dllsearchpath:$libdir";;
+	  esac
+	  ;;
+	esac
+      done
+      # Substitute the hardcoded libdirs into the rpath.
+      if test -n "$hardcode_libdir_separator" &&
+	 test -n "$hardcode_libdirs"; then
+	libdir="$hardcode_libdirs"
+	eval rpath=\" $hardcode_libdir_flag_spec\"
+      fi
+      compile_rpath="$rpath"
+
+      rpath=
+      hardcode_libdirs=
+      for libdir in $finalize_rpath; do
+	if test -n "$hardcode_libdir_flag_spec"; then
+	  if test -n "$hardcode_libdir_separator"; then
+	    if test -z "$hardcode_libdirs"; then
+	      hardcode_libdirs="$libdir"
+	    else
+	      # Just accumulate the unique libdirs.
+	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+		;;
+	      *)
+		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+		;;
+	      esac
+	    fi
+	  else
+	    eval flag=\"$hardcode_libdir_flag_spec\"
+	    rpath="$rpath $flag"
+	  fi
+	elif test -n "$runpath_var"; then
+	  case "$finalize_perm_rpath " in
+	  *" $libdir "*) ;;
+	  *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
+	  esac
+	fi
+      done
+      # Substitute the hardcoded libdirs into the rpath.
+      if test -n "$hardcode_libdir_separator" &&
+	 test -n "$hardcode_libdirs"; then
+	libdir="$hardcode_libdirs"
+	eval rpath=\" $hardcode_libdir_flag_spec\"
+      fi
+      finalize_rpath="$rpath"
+
+      if test -n "$libobjs" && test "$build_old_libs" = yes; then
+	# Transform all the library objects into standard objects.
+	compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+	finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+      fi
+
+      dlsyms=
+      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+	if test -n "$NM" && test -n "$global_symbol_pipe"; then
+	  dlsyms="${outputname}S.c"
+	else
+	  $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2
+	fi
+      fi
+
+      if test -n "$dlsyms"; then
+	case $dlsyms in
+	"") ;;
+	*.c)
+	  # Discover the nlist of each of the dlfiles.
+	  nlist="$output_objdir/${outputname}.nm"
+
+	  $show "$rm $nlist ${nlist}S ${nlist}T"
+	  $run $rm "$nlist" "${nlist}S" "${nlist}T"
+
+	  # Parse the name list into a source file.
+	  $show "creating $output_objdir/$dlsyms"
+
+	  test -z "$run" && $echo > "$output_objdir/$dlsyms" "\
+/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */
+/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */
+
+#ifdef __cplusplus
+extern \"C\" {
+#endif
+
+/* Prevent the only kind of declaration conflicts we can make. */
+#define lt_preloaded_symbols some_other_symbol
+
+/* External symbol declarations for the compiler. */\
+"
+
+	  if test "$dlself" = yes; then
+	    $show "generating symbol list for \`$output'"
+
+	    test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist"
+
+	    # Add our own program objects to the symbol list.
+	    progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+	    for arg in $progfiles; do
+	      $show "extracting global C symbols from \`$arg'"
+	      $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
+	    done
+
+	    if test -n "$exclude_expsyms"; then
+	      $run eval 'egrep -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
+	      $run eval '$mv "$nlist"T "$nlist"'
+	    fi
+
+	    if test -n "$export_symbols_regex"; then
+	      $run eval 'egrep -e "$export_symbols_regex" "$nlist" > "$nlist"T'
+	      $run eval '$mv "$nlist"T "$nlist"'
+	    fi
+
+	    # Prepare the list of exported symbols
+	    if test -z "$export_symbols"; then
+	      export_symbols="$output_objdir/$output.exp"
+	      $run $rm $export_symbols
+	      $run eval "sed -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
+	    else
+	      $run eval "sed -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"'
+	      $run eval 'grep -f "$output_objdir/$output.exp" < "$nlist" > "$nlist"T'
+	      $run eval 'mv "$nlist"T "$nlist"'
+	    fi
+	  fi
+
+	  for arg in $dlprefiles; do
+	    $show "extracting global C symbols from \`$arg'"
+	    name=`echo "$arg" | sed -e 's%^.*/%%'`
+	    $run eval 'echo ": $name " >> "$nlist"'
+	    $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
+	  done
+
+	  if test -z "$run"; then
+	    # Make sure we have at least an empty file.
+	    test -f "$nlist" || : > "$nlist"
+
+	    if test -n "$exclude_expsyms"; then
+	      egrep -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
+	      $mv "$nlist"T "$nlist"
+	    fi
+
+	    # Try sorting and uniquifying the output.
+	    if grep -v "^: " < "$nlist" | sort +2 | uniq > "$nlist"S; then
+	      :
+	    else
+	      grep -v "^: " < "$nlist" > "$nlist"S
+	    fi
+
+	    if test -f "$nlist"S; then
+	      eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"'
+	    else
+	      echo '/* NONE */' >> "$output_objdir/$dlsyms"
+	    fi
+
+	    $echo >> "$output_objdir/$dlsyms" "\
+
+#undef lt_preloaded_symbols
+
+#if defined (__STDC__) && __STDC__
+# define lt_ptr void *
+#else
+# define lt_ptr char *
+# define const
+#endif
+
+/* The mapping between symbol names and symbols. */
+const struct {
+  const char *name;
+  lt_ptr address;
+}
+lt_preloaded_symbols[] =
+{\
+"
+
+	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms"
+
+	    $echo >> "$output_objdir/$dlsyms" "\
+  {0, (lt_ptr) 0}
+};
+
+/* This works around a problem in FreeBSD linker */
+#ifdef FREEBSD_WORKAROUND
+static const void *lt_preloaded_setup() {
+  return lt_preloaded_symbols;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif\
+"
+	  fi
+
+	  pic_flag_for_symtable=
+	  case $host in
+	  # compiling the symbol table file with pic_flag works around
+	  # a FreeBSD bug that causes programs to crash when -lm is
+	  # linked before any other PIC object.  But we must not use
+	  # pic_flag when linking with -static.  The problem exists in
+	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
+	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
+	    case "$compile_command " in
+	    *" -static "*) ;;
+	    *) pic_flag_for_symtable=" $pic_flag -DPIC -DFREEBSD_WORKAROUND";;
+	    esac;;
+	  *-*-hpux*)
+	    case "$compile_command " in
+	    *" -static "*) ;;
+	    *) pic_flag_for_symtable=" $pic_flag -DPIC";;
+	    esac
+	  esac
+
+	  # Now compile the dynamic symbol file.
+	  $show "(cd $output_objdir && $CC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
+	  $run eval '(cd $output_objdir && $CC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
+
+	  # Clean up the generated files.
+	  $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
+	  $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
+
+	  # Transform the symbol file into the correct name.
+	  compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
+	  finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
+	  ;;
+	*)
+	  $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
+	  exit 1
+	  ;;
+	esac
+      else
+	# We keep going just in case the user didn't refer to
+	# lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
+	# really was required.
+
+	# Nullify the symbol file.
+	compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
+	finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
+      fi
+
+      if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
+	# Replace the output file specification.
+	compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
+	link_command="$compile_command$compile_rpath"
+
+	# We have no uninstalled library dependencies, so finalize right now.
+	$show "$link_command"
+	$run eval "$link_command"
+	status=$?
+
+	# Delete the generated files.
+	if test -n "$dlsyms"; then
+	  $show "$rm $output_objdir/${outputname}S.${objext}"
+	  $run $rm "$output_objdir/${outputname}S.${objext}"
+	fi
+
+	exit $status
+      fi
+
+      if test -n "$shlibpath_var"; then
+	# We should set the shlibpath_var
+	rpath=
+	for dir in $temp_rpath; do
+	  case $dir in
+	  [\\/]* | [A-Za-z]:[\\/]*)
+	    # Absolute path.
+	    rpath="$rpath$dir:"
+	    ;;
+	  *)
+	    # Relative path: add a thisdir entry.
+	    rpath="$rpath\$thisdir/$dir:"
+	    ;;
+	  esac
+	done
+	temp_rpath="$rpath"
+      fi
+
+      if test -n "$compile_shlibpath$finalize_shlibpath"; then
+	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
+      fi
+      if test -n "$finalize_shlibpath"; then
+	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
+      fi
+
+      compile_var=
+      finalize_var=
+      if test -n "$runpath_var"; then
+	if test -n "$perm_rpath"; then
+	  # We should set the runpath_var.
+	  rpath=
+	  for dir in $perm_rpath; do
+	    rpath="$rpath$dir:"
+	  done
+	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
+	fi
+	if test -n "$finalize_perm_rpath"; then
+	  # We should set the runpath_var.
+	  rpath=
+	  for dir in $finalize_perm_rpath; do
+	    rpath="$rpath$dir:"
+	  done
+	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
+	fi
+      fi
+
+      if test "$no_install" = yes; then
+	# We don't need to create a wrapper script.
+	link_command="$compile_var$compile_command$compile_rpath"
+	# Replace the output file specification.
+	link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
+	# Delete the old output file.
+	$run $rm $output
+	# Link the executable and exit
+	$show "$link_command"
+	$run eval "$link_command" || exit $?
+	exit 0
+      fi
+
+      if test "$hardcode_action" = relink; then
+	# Fast installation is not supported
+	link_command="$compile_var$compile_command$compile_rpath"
+	relink_command="$finalize_var$finalize_command$finalize_rpath"
+
+	$echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2
+	$echo "$modename: \`$output' will be relinked during installation" 1>&2
+      else
+	if test "$fast_install" != no; then
+	  link_command="$finalize_var$compile_command$finalize_rpath"
+	  if test "$fast_install" = yes; then
+	    relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
+	  else
+	    # fast_install is set to needless
+	    relink_command=
+	  fi
+	else
+	  link_command="$compile_var$compile_command$compile_rpath"
+	  relink_command="$finalize_var$finalize_command$finalize_rpath"
+	fi
+      fi
+
+      # Replace the output file specification.
+      link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
+
+      # Delete the old output files.
+      $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname
+
+      $show "$link_command"
+      $run eval "$link_command" || exit $?
+
+      # Now create the wrapper script.
+      $show "creating $output"
+
+      # Quote the relink command for shipping.
+      if test -n "$relink_command"; then
+	# Preserve any variables that may affect compiler behavior
+	for var in $variables_saved_for_relink; do
+	  if eval test -z \"\${$var+set}\"; then
+	    relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
+	  elif eval var_value=\$$var; test -z "$var_value"; then
+	    relink_command="$var=; export $var; $relink_command"
+	  else
+	    var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
+	    relink_command="$var=\"$var_value\"; export $var; $relink_command"
+	  fi
+	done
+	relink_command="(cd `pwd`; $relink_command)"
+	relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
+      fi
+
+      # Quote $echo for shipping.
+      if test "X$echo" = "X$SHELL $0 --fallback-echo"; then
+	case $0 in
+	[\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $0 --fallback-echo";;
+	*) qecho="$SHELL `pwd`/$0 --fallback-echo";;
+	esac
+	qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"`
+      else
+	qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"`
+      fi
+
+      # Only actually do things if our run command is non-null.
+      if test -z "$run"; then
+	# win32 will think the script is a binary if it has
+	# a .exe suffix, so we strip it off here.
+	case $output in
+	  *.exe) output=`echo $output|sed 's,.exe$,,'` ;;
+	esac
+	# test for cygwin because mv fails w/o .exe extensions
+	case $host in
+	  *cygwin*) exeext=.exe ;;
+	  *) exeext= ;;
+	esac
+	$rm $output
+	trap "$rm $output; exit 1" 1 2 15
+
+	$echo > $output "\
+#! $SHELL
+
+# $output - temporary wrapper script for $objdir/$outputname
+# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
+#
+# The $output program cannot be directly executed until all the libtool
+# libraries that it depends on are installed.
+#
+# This wrapper script should never be moved out of the build directory.
+# If it is, it will not operate correctly.
+
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed='sed -e 1s/^X//'
+sed_quote_subst='$sed_quote_subst'
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+if test \"\${CDPATH+set}\" = set; then CDPATH=:; export CDPATH; fi
+
+relink_command=\"$relink_command\"
+
+# This environment variable determines our operation mode.
+if test \"\$libtool_install_magic\" = \"$magic\"; then
+  # install mode needs the following variable:
+  notinst_deplibs='$notinst_deplibs'
+else
+  # When we are sourced in execute mode, \$file and \$echo are already set.
+  if test \"\$libtool_execute_magic\" != \"$magic\"; then
+    echo=\"$qecho\"
+    file=\"\$0\"
+    # Make sure echo works.
+    if test \"X\$1\" = X--no-reexec; then
+      # Discard the --no-reexec flag, and continue.
+      shift
+    elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then
+      # Yippee, \$echo works!
+      :
+    else
+      # Restart under the correct shell, and then maybe \$echo will work.
+      exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
+    fi
+  fi\
+"
+	$echo >> $output "\
+
+  # Find the directory that this script lives in.
+  thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
+  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
+
+  # Follow symbolic links until we get to the real thisdir.
+  file=\`ls -ld \"\$file\" | sed -n 's/.*-> //p'\`
+  while test -n \"\$file\"; do
+    destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
+
+    # If there was a directory component, then change thisdir.
+    if test \"x\$destdir\" != \"x\$file\"; then
+      case \"\$destdir\" in
+      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
+      *) thisdir=\"\$thisdir/\$destdir\" ;;
+      esac
+    fi
+
+    file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
+    file=\`ls -ld \"\$thisdir/\$file\" | sed -n 's/.*-> //p'\`
+  done
+
+  # Try to get the absolute directory name.
+  absdir=\`cd \"\$thisdir\" && pwd\`
+  test -n \"\$absdir\" && thisdir=\"\$absdir\"
+"
+
+	if test "$fast_install" = yes; then
+	  echo >> $output "\
+  program=lt-'$outputname'$exeext
+  progdir=\"\$thisdir/$objdir\"
+
+  if test ! -f \"\$progdir/\$program\" || \\
+     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | sed 1q\`; \\
+       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
+
+    file=\"\$\$-\$program\"
+
+    if test ! -d \"\$progdir\"; then
+      $mkdir \"\$progdir\"
+    else
+      $rm \"\$progdir/\$file\"
+    fi"
+
+	  echo >> $output "\
+
+    # relink executable if necessary
+    if test -n \"\$relink_command\"; then
+      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
+      else
+	$echo \"\$relink_command_output\" >&2
+	$rm \"\$progdir/\$file\"
+	exit 1
+      fi
+    fi
+
+    $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
+    { $rm \"\$progdir/\$program\";
+      $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; }
+    $rm \"\$progdir/\$file\"
+  fi"
+	else
+	  echo >> $output "\
+  program='$outputname'
+  progdir=\"\$thisdir/$objdir\"
+"
+	fi
+
+	echo >> $output "\
+
+  if test -f \"\$progdir/\$program\"; then"
+
+	# Export our shlibpath_var if we have one.
+	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
+	  $echo >> $output "\
+    # Add our own library path to $shlibpath_var
+    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
+
+    # Some systems cannot cope with colon-terminated $shlibpath_var
+    # The second colon is a workaround for a bug in BeOS R4 sed
+    $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
+
+    export $shlibpath_var
+"
+	fi
+
+	# fixup the dll searchpath if we need to.
+	if test -n "$dllsearchpath"; then
+	  $echo >> $output "\
+    # Add the dll search path components to the executable PATH
+    PATH=$dllsearchpath:\$PATH
+"
+	fi
+
+	$echo >> $output "\
+    if test \"\$libtool_execute_magic\" != \"$magic\"; then
+      # Run the actual program with our arguments.
+"
+	case $host in
+	# win32 systems need to use the prog path for dll
+	# lookup to work
+	*-*-cygwin* | *-*-pw32*)
+	  $echo >> $output "\
+      exec \$progdir/\$program \${1+\"\$@\"}
+"
+	  ;;
+
+	# Backslashes separate directories on plain windows
+	*-*-mingw | *-*-os2*)
+	  $echo >> $output "\
+      exec \$progdir\\\\\$program \${1+\"\$@\"}
+"
+	  ;;
+
+	*)
+	  $echo >> $output "\
+      # Export the path to the program.
+      PATH=\"\$progdir:\$PATH\"
+      export PATH
+
+      exec \$program \${1+\"\$@\"}
+"
+	  ;;
+	esac
+	$echo >> $output "\
+      \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\"
+      exit 1
+    fi
+  else
+    # The program doesn't exist.
+    \$echo \"\$0: error: \$progdir/\$program does not exist\" 1>&2
+    \$echo \"This script is just a wrapper for \$program.\" 1>&2
+    echo \"See the $PACKAGE documentation for more information.\" 1>&2
+    exit 1
+  fi
+fi\
+"
+	chmod +x $output
+      fi
+      exit 0
+      ;;
+    esac
+
+    # See if we need to build an old-fashioned archive.
+    for oldlib in $oldlibs; do
+
+      if test "$build_libtool_libs" = convenience; then
+	oldobjs="$libobjs_save"
+	addlibs="$convenience"
+	build_libtool_libs=no
+      else
+	if test "$build_libtool_libs" = module; then
+	  oldobjs="$libobjs_save"
+	  build_libtool_libs=no
+	else
+	  oldobjs="$objs$old_deplibs "`$echo "X$libobjs_save" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`
+	fi
+	addlibs="$old_convenience"
+      fi
+
+      if test -n "$addlibs"; then
+	gentop="$output_objdir/${outputname}x"
+	$show "${rm}r $gentop"
+	$run ${rm}r "$gentop"
+	$show "mkdir $gentop"
+	$run mkdir "$gentop"
+	status=$?
+	if test "$status" -ne 0 && test ! -d "$gentop"; then
+	  exit $status
+	fi
+	generated="$generated $gentop"
+
+	# Add in members from convenience archives.
+	for xlib in $addlibs; do
+	  # Extract the objects.
+	  case $xlib in
+	  [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
+	  *) xabs=`pwd`"/$xlib" ;;
+	  esac
+	  xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
+	  xdir="$gentop/$xlib"
+
+	  $show "${rm}r $xdir"
+	  $run ${rm}r "$xdir"
+	  $show "mkdir $xdir"
+	  $run mkdir "$xdir"
+	  status=$?
+	  if test "$status" -ne 0 && test ! -d "$xdir"; then
+	    exit $status
+	  fi
+	  $show "(cd $xdir && $AR x $xabs)"
+	  $run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
+
+	  oldobjs="$oldobjs "`find $xdir -name \*.${objext} -print -o -name \*.lo -print | $NL2SP`
+	done
+      fi
+
+      # Do each command in the archive commands.
+      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
+	eval cmds=\"$old_archive_from_new_cmds\"
+      else
+	# Ensure that we have .o objects in place in case we decided
+	# not to build a shared library, and have fallen back to building
+	# static libs even though --disable-static was passed!
+	for oldobj in $oldobjs; do
+	  if test ! -f $oldobj; then
+	    xdir=`$echo "X$oldobj" | $Xsed -e 's%/[^/]*$%%'`
+	    if test "X$xdir" = "X$oldobj"; then
+	      xdir="."
+	    else
+	      xdir="$xdir"
+	    fi
+	    baseobj=`$echo "X$oldobj" | $Xsed -e 's%^.*/%%'`
+	    obj=`$echo "X$baseobj" | $Xsed -e "$o2lo"`
+	    $show "(cd $xdir && ${LN_S} $obj $baseobj)"
+	    $run eval '(cd $xdir && ${LN_S} $obj $baseobj)' || exit $?
+	  fi
+	done
+
+	eval cmds=\"$old_archive_cmds\"
+      fi
+      save_ifs="$IFS"; IFS='~'
+      for cmd in $cmds; do
+	IFS="$save_ifs"
+	$show "$cmd"
+	$run eval "$cmd" || exit $?
+      done
+      IFS="$save_ifs"
+    done
+
+    if test -n "$generated"; then
+      $show "${rm}r$generated"
+      $run ${rm}r$generated
+    fi
+
+    # Now create the libtool archive.
+    case $output in
+    *.la)
+      old_library=
+      test "$build_old_libs" = yes && old_library="$libname.$libext"
+      $show "creating $output"
+
+      # Preserve any variables that may affect compiler behavior
+      for var in $variables_saved_for_relink; do
+	if eval test -z \"\${$var+set}\"; then
+	  relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
+	elif eval var_value=\$$var; test -z "$var_value"; then
+	  relink_command="$var=; export $var; $relink_command"
+	else
+	  var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
+	  relink_command="$var=\"$var_value\"; export $var; $relink_command"
+	fi
+      done
+      # Quote the link command for shipping.
+      relink_command="(cd `pwd`; $SHELL $0 --mode=relink $libtool_args @inst_prefix_dir@)"
+      relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
+
+      # Only create the output if not a dry run.
+      if test -z "$run"; then
+	for installed in no yes; do
+	  if test "$installed" = yes; then
+	    if test -z "$install_libdir"; then
+	      break
+	    fi
+	    output="$output_objdir/$outputname"i
+	    # Replace all uninstalled libtool libraries with the installed ones
+	    newdependency_libs=
+	    for deplib in $dependency_libs; do
+	      case $deplib in
+	      *.la)
+		name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'`
+		eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
+		if test -z "$libdir"; then
+		  $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
+		  exit 1
+		fi
+		newdependency_libs="$newdependency_libs $libdir/$name"
+		;;
+	      *) newdependency_libs="$newdependency_libs $deplib" ;;
+	      esac
+	    done
+	    dependency_libs="$newdependency_libs"
+	    newdlfiles=
+	    for lib in $dlfiles; do
+	      name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
+	      eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+	      if test -z "$libdir"; then
+		$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
+		exit 1
+	      fi
+	      newdlfiles="$newdlfiles $libdir/$name"
+	    done
+	    dlfiles="$newdlfiles"
+	    newdlprefiles=
+	    for lib in $dlprefiles; do
+	      name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
+	      eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+	      if test -z "$libdir"; then
+		$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
+		exit 1
+	      fi
+	      newdlprefiles="$newdlprefiles $libdir/$name"
+	    done
+	    dlprefiles="$newdlprefiles"
+	  fi
+	  $rm $output
+	  # place dlname in correct position for cygwin
+	  tdlname=$dlname
+	  case $host,$output,$installed,$module,$dlname in
+	    *cygwin*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
+	  esac
+	  $echo > $output "\
+# $outputname - a libtool library file
+# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# The name that we can dlopen(3).
+dlname='$tdlname'
+
+# Names of this library.
+library_names='$library_names'
+
+# The name of the static archive.
+old_library='$old_library'
+
+# Libraries that this one depends upon.
+dependency_libs='$dependency_libs'
+
+# Version information for $libname.
+current=$current
+age=$age
+revision=$revision
+
+# Is this an already installed library?
+installed=$installed
+
+# Files to dlopen/dlpreopen
+dlopen='$dlfiles'
+dlpreopen='$dlprefiles'
+
+# Directory that this library needs to be installed in:
+libdir='$install_libdir'"
+	  if test "$installed" = no && test "$need_relink" = yes; then
+	    $echo >> $output "\
+relink_command=\"$relink_command\""
+	  fi
+	done
+      fi
+
+      # Do a symbolic link so that the libtool archive can be found in
+      # LD_LIBRARY_PATH before the program is installed.
+      $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)"
+      $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $?
+      ;;
+    esac
+    exit 0
+    ;;
+
+  # libtool install mode
+  install)
+    modename="$modename: install"
+
+    # There may be an optional sh(1) argument at the beginning of
+    # install_prog (especially on Windows NT).
+    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
+       # Allow the use of GNU shtool's install command.
+       $echo "X$nonopt" | $Xsed | grep shtool > /dev/null; then
+      # Aesthetically quote it.
+      arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"`
+      case $arg in
+      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*)
+	arg="\"$arg\""
+	;;
+      esac
+      install_prog="$arg "
+      arg="$1"
+      shift
+    else
+      install_prog=
+      arg="$nonopt"
+    fi
+
+    # The real first argument should be the name of the installation program.
+    # Aesthetically quote it.
+    arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
+    case $arg in
+    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*)
+      arg="\"$arg\""
+      ;;
+    esac
+    install_prog="$install_prog$arg"
+
+    # We need to accept at least all the BSD install flags.
+    dest=
+    files=
+    opts=
+    prev=
+    install_type=
+    isdir=no
+    stripme=
+    for arg
+    do
+      if test -n "$dest"; then
+	files="$files $dest"
+	dest="$arg"
+	continue
+      fi
+
+      case $arg in
+      -d) isdir=yes ;;
+      -f) prev="-f" ;;
+      -g) prev="-g" ;;
+      -m) prev="-m" ;;
+      -o) prev="-o" ;;
+      -s)
+	stripme=" -s"
+	continue
+	;;
+      -*) ;;
+
+      *)
+	# If the previous option needed an argument, then skip it.
+	if test -n "$prev"; then
+	  prev=
+	else
+	  dest="$arg"
+	  continue
+	fi
+	;;
+      esac
+
+      # Aesthetically quote the argument.
+      arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
+      case $arg in
+      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*)
+	arg="\"$arg\""
+	;;
+      esac
+      install_prog="$install_prog $arg"
+    done
+
+    if test -z "$install_prog"; then
+      $echo "$modename: you must specify an install program" 1>&2
+      $echo "$help" 1>&2
+      exit 1
+    fi
+
+    if test -n "$prev"; then
+      $echo "$modename: the \`$prev' option requires an argument" 1>&2
+      $echo "$help" 1>&2
+      exit 1
+    fi
+
+    if test -z "$files"; then
+      if test -z "$dest"; then
+	$echo "$modename: no file or destination specified" 1>&2
+      else
+	$echo "$modename: you must specify a destination" 1>&2
+      fi
+      $echo "$help" 1>&2
+      exit 1
+    fi
+
+    # Strip any trailing slash from the destination.
+    dest=`$echo "X$dest" | $Xsed -e 's%/$%%'`
+
+    # Check to see that the destination is a directory.
+    test -d "$dest" && isdir=yes
+    if test "$isdir" = yes; then
+      destdir="$dest"
+      destname=
+    else
+      destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'`
+      test "X$destdir" = "X$dest" && destdir=.
+      destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'`
+
+      # Not a directory, so check to see that there is only one file specified.
+      set dummy $files
+      if test "$#" -gt 2; then
+	$echo "$modename: \`$dest' is not a directory" 1>&2
+	$echo "$help" 1>&2
+	exit 1
+      fi
+    fi
+    case $destdir in
+    [\\/]* | [A-Za-z]:[\\/]*) ;;
+    *)
+      for file in $files; do
+	case $file in
+	*.lo) ;;
+	*)
+	  $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2
+	  $echo "$help" 1>&2
+	  exit 1
+	  ;;
+	esac
+      done
+      ;;
+    esac
+
+    # This variable tells wrapper scripts just to set variables rather
+    # than running their programs.
+    libtool_install_magic="$magic"
+
+    staticlibs=
+    future_libdirs=
+    current_libdirs=
+    for file in $files; do
+
+      # Do each installation.
+      case $file in
+      *.$libext)
+	# Do the static libraries later.
+	staticlibs="$staticlibs $file"
+	;;
+
+      *.la)
+	# Check to see that this really is a libtool archive.
+	if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
+	else
+	  $echo "$modename: \`$file' is not a valid libtool archive" 1>&2
+	  $echo "$help" 1>&2
+	  exit 1
+	fi
+
+	library_names=
+	old_library=
+	relink_command=
+	# If there is no directory component, then add one.
+	case $file in
+	*/* | *\\*) . $file ;;
+	*) . ./$file ;;
+	esac
+
+	# Add the libdir to current_libdirs if it is the destination.
+	if test "X$destdir" = "X$libdir"; then
+	  case "$current_libdirs " in
+	  *" $libdir "*) ;;
+	  *) current_libdirs="$current_libdirs $libdir" ;;
+	  esac
+	else
+	  # Note the libdir as a future libdir.
+	  case "$future_libdirs " in
+	  *" $libdir "*) ;;
+	  *) future_libdirs="$future_libdirs $libdir" ;;
+	  esac
+	fi
+
+	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/
+	test "X$dir" = "X$file/" && dir=
+	dir="$dir$objdir"
+
+	if test -n "$relink_command"; then
+	  # Determine the prefix the user has applied to our future dir.
+	  inst_prefix_dir=`$echo "$destdir" | sed "s%$libdir\$%%"`
+
+	  # Don't allow the user to place us outside of our expected
+	  # location b/c this prevents finding dependent libraries that
+	  # are installed to the same prefix.
+	  if test "$inst_prefix_dir" = "$destdir"; then
+	    $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2
+	    exit 1
+	  fi
+
+	  if test -n "$inst_prefix_dir"; then
+	    # Stick the inst_prefix_dir data into the link command.
+	    relink_command=`$echo "$relink_command" | sed "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
+	  else
+	    relink_command=`$echo "$relink_command" | sed "s%@inst_prefix_dir@%%"`
+	  fi
+
+	  $echo "$modename: warning: relinking \`$file'" 1>&2
+	  $show "$relink_command"
+	  if $run eval "$relink_command"; then :
+	  else
+	    $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
+	    exit 1
+	  fi
+	fi
+
+	# See the names of the shared library.
+	set dummy $library_names
+	if test -n "$2"; then
+	  realname="$2"
+	  shift
+	  shift
+
+	  srcname="$realname"
+	  test -n "$relink_command" && srcname="$realname"T
+
+	  # Install the shared library and build the symlinks.
+	  $show "$install_prog $dir/$srcname $destdir/$realname"
+	  $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $?
+	  if test -n "$stripme" && test -n "$striplib"; then
+	    $show "$striplib $destdir/$realname"
+	    $run eval "$striplib $destdir/$realname" || exit $?
+	  fi
+
+	  if test "$#" -gt 0; then
+	    # Delete the old symlinks, and create new ones.
+	    for linkname
+	    do
+	      if test "$linkname" != "$realname"; then
+		$show "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)"
+		$run eval "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)"
+	      fi
+	    done
+	  fi
+
+	  # Do each command in the postinstall commands.
+	  lib="$destdir/$realname"
+	  eval cmds=\"$postinstall_cmds\"
+	  save_ifs="$IFS"; IFS='~'
+	  for cmd in $cmds; do
+	    IFS="$save_ifs"
+	    $show "$cmd"
+	    $run eval "$cmd" || exit $?
+	  done
+	  IFS="$save_ifs"
+	fi
+
+	# Install the pseudo-library for information purposes.
+	name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
+	instname="$dir/$name"i
+	$show "$install_prog $instname $destdir/$name"
+	$run eval "$install_prog $instname $destdir/$name" || exit $?
+
+	# Maybe install the static library, too.
+	test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
+	;;
+
+      *.lo)
+	# Install (i.e. copy) a libtool object.
+
+	# Figure out destination file name, if it wasn't already specified.
+	if test -n "$destname"; then
+	  destfile="$destdir/$destname"
+	else
+	  destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
+	  destfile="$destdir/$destfile"
+	fi
+
+	# Deduce the name of the destination old-style object file.
+	case $destfile in
+	*.lo)
+	  staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"`
+	  ;;
+	*.$objext)
+	  staticdest="$destfile"
+	  destfile=
+	  ;;
+	*)
+	  $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2
+	  $echo "$help" 1>&2
+	  exit 1
+	  ;;
+	esac
+
+	# Install the libtool object if requested.
+	if test -n "$destfile"; then
+	  $show "$install_prog $file $destfile"
+	  $run eval "$install_prog $file $destfile" || exit $?
+	fi
+
+	# Install the old object if enabled.
+	if test "$build_old_libs" = yes; then
+	  # Deduce the name of the old-style object file.
+	  staticobj=`$echo "X$file" | $Xsed -e "$lo2o"`
+
+	  $show "$install_prog $staticobj $staticdest"
+	  $run eval "$install_prog \$staticobj \$staticdest" || exit $?
+	fi
+	exit 0
+	;;
+
+      *)
+	# Figure out destination file name, if it wasn't already specified.
+	if test -n "$destname"; then
+	  destfile="$destdir/$destname"
+	else
+	  destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
+	  destfile="$destdir/$destfile"
+	fi
+
+	# Do a test to see if this is really a libtool program.
+	if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+	  notinst_deplibs=
+	  relink_command=
+
+	  # If there is no directory component, then add one.
+	  case $file in
+	  */* | *\\*) . $file ;;
+	  *) . ./$file ;;
+	  esac
+
+	  # Check the variables that should have been set.
+	  if test -z "$notinst_deplibs"; then
+	    $echo "$modename: invalid libtool wrapper script \`$file'" 1>&2
+	    exit 1
+	  fi
+
+	  finalize=yes
+	  for lib in $notinst_deplibs; do
+	    # Check to see that each library is installed.
+	    libdir=
+	    if test -f "$lib"; then
+	      # If there is no directory component, then add one.
+	      case $lib in
+	      */* | *\\*) . $lib ;;
+	      *) . ./$lib ;;
+	      esac
+	    fi
+	    libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
+	    if test -n "$libdir" && test ! -f "$libfile"; then
+	      $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2
+	      finalize=no
+	    fi
+	  done
+
+	  relink_command=
+	  # If there is no directory component, then add one.
+	  case $file in
+	  */* | *\\*) . $file ;;
+	  *) . ./$file ;;
+	  esac
+
+	  outputname=
+	  if test "$fast_install" = no && test -n "$relink_command"; then
+	    if test "$finalize" = yes && test -z "$run"; then
+	      tmpdir="/tmp"
+	      test -n "$TMPDIR" && tmpdir="$TMPDIR"
+              tmpdir=`mktemp -d $tmpdir/libtool-XXXXXX 2> /dev/null`
+              if test $? = 0 ; then :
+              else
+                tmpdir="$tmpdir/libtool-$$"
+              fi
+	      if $mkdir -p "$tmpdir" && chmod 700 "$tmpdir"; then :
+	      else
+		$echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2
+		continue
+	      fi
+	      file=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
+	      outputname="$tmpdir/$file"
+	      # Replace the output file specification.
+	      relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
+
+	      $show "$relink_command"
+	      if $run eval "$relink_command"; then :
+	      else
+		$echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
+		${rm}r "$tmpdir"
+		continue
+	      fi
+	      file="$outputname"
+	    else
+	      $echo "$modename: warning: cannot relink \`$file'" 1>&2
+	    fi
+	  else
+	    # Install the binary that we compiled earlier.
+	    file=`$echo "X$file" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
+	  fi
+	fi
+
+	# remove .exe since cygwin /usr/bin/install will append another
+	# one anyways
+	case $install_prog,$host in
+	/usr/bin/install*,*cygwin*)
+	  case $file:$destfile in
+	  *.exe:*.exe)
+	    # this is ok
+	    ;;
+	  *.exe:*)
+	    destfile=$destfile.exe
+	    ;;
+	  *:*.exe)
+	    destfile=`echo $destfile | sed -e 's,.exe$,,'`
+	    ;;
+	  esac
+	  ;;
+	esac
+	$show "$install_prog$stripme $file $destfile"
+	$run eval "$install_prog\$stripme \$file \$destfile" || exit $?
+	test -n "$outputname" && ${rm}r "$tmpdir"
+	;;
+      esac
+    done
+
+    for file in $staticlibs; do
+      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
+
+      # Set up the ranlib parameters.
+      oldlib="$destdir/$name"
+
+      $show "$install_prog $file $oldlib"
+      $run eval "$install_prog \$file \$oldlib" || exit $?
+
+      if test -n "$stripme" && test -n "$striplib"; then
+	$show "$old_striplib $oldlib"
+	$run eval "$old_striplib $oldlib" || exit $?
+      fi
+
+      # Do each command in the postinstall commands.
+      eval cmds=\"$old_postinstall_cmds\"
+      save_ifs="$IFS"; IFS='~'
+      for cmd in $cmds; do
+	IFS="$save_ifs"
+	$show "$cmd"
+	$run eval "$cmd" || exit $?
+      done
+      IFS="$save_ifs"
+    done
+
+    if test -n "$future_libdirs"; then
+      $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2
+    fi
+
+    if test -n "$current_libdirs"; then
+      # Maybe just do a dry run.
+      test -n "$run" && current_libdirs=" -n$current_libdirs"
+      exec_cmd='$SHELL $0 --finish$current_libdirs'
+    else
+      exit 0
+    fi
+    ;;
+
+  # libtool finish mode
+  finish)
+    modename="$modename: finish"
+    libdirs="$nonopt"
+    admincmds=
+
+    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
+      for dir
+      do
+	libdirs="$libdirs $dir"
+      done
+
+      for libdir in $libdirs; do
+	if test -n "$finish_cmds"; then
+	  # Do each command in the finish commands.
+	  eval cmds=\"$finish_cmds\"
+	  save_ifs="$IFS"; IFS='~'
+	  for cmd in $cmds; do
+	    IFS="$save_ifs"
+	    $show "$cmd"
+	    $run eval "$cmd" || admincmds="$admincmds
+       $cmd"
+	  done
+	  IFS="$save_ifs"
+	fi
+	if test -n "$finish_eval"; then
+	  # Do the single finish_eval.
+	  eval cmds=\"$finish_eval\"
+	  $run eval "$cmds" || admincmds="$admincmds
+       $cmds"
+	fi
+      done
+    fi
+
+    # Exit here if they wanted silent mode.
+    test "$show" = : && exit 0
+
+    echo "----------------------------------------------------------------------"
+    echo "Libraries have been installed in:"
+    for libdir in $libdirs; do
+      echo "   $libdir"
+    done
+    echo
+    echo "If you ever happen to want to link against installed libraries"
+    echo "in a given directory, LIBDIR, you must either use libtool, and"
+    echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
+    echo "flag during linking and do at least one of the following:"
+    if test -n "$shlibpath_var"; then
+      echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
+      echo "     during execution"
+    fi
+    if test -n "$runpath_var"; then
+      echo "   - add LIBDIR to the \`$runpath_var' environment variable"
+      echo "     during linking"
+    fi
+    if test -n "$hardcode_libdir_flag_spec"; then
+      libdir=LIBDIR
+      eval flag=\"$hardcode_libdir_flag_spec\"
+
+      echo "   - use the \`$flag' linker flag"
+    fi
+    if test -n "$admincmds"; then
+      echo "   - have your system administrator run these commands:$admincmds"
+    fi
+    if test -f /etc/ld.so.conf; then
+      echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
+    fi
+    echo
+    echo "See any operating system documentation about shared libraries for"
+    echo "more information, such as the ld(1) and ld.so(8) manual pages."
+    echo "----------------------------------------------------------------------"
+    exit 0
+    ;;
+
+  # libtool execute mode
+  execute)
+    modename="$modename: execute"
+
+    # The first argument is the command name.
+    cmd="$nonopt"
+    if test -z "$cmd"; then
+      $echo "$modename: you must specify a COMMAND" 1>&2
+      $echo "$help"
+      exit 1
+    fi
+
+    # Handle -dlopen flags immediately.
+    for file in $execute_dlfiles; do
+      if test ! -f "$file"; then
+	$echo "$modename: \`$file' is not a file" 1>&2
+	$echo "$help" 1>&2
+	exit 1
+      fi
+
+      dir=
+      case $file in
+      *.la)
+	# Check to see that this really is a libtool archive.
+	if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
+	else
+	  $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
+	  $echo "$help" 1>&2
+	  exit 1
+	fi
+
+	# Read the libtool library.
+	dlname=
+	library_names=
+
+	# If there is no directory component, then add one.
+	case $file in
+	*/* | *\\*) . $file ;;
+	*) . ./$file ;;
+	esac
+
+	# Skip this library if it cannot be dlopened.
+	if test -z "$dlname"; then
+	  # Warn if it was a shared library.
+	  test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'"
+	  continue
+	fi
+
+	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
+	test "X$dir" = "X$file" && dir=.
+
+	if test -f "$dir/$objdir/$dlname"; then
+	  dir="$dir/$objdir"
+	else
+	  $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2
+	  exit 1
+	fi
+	;;
+
+      *.lo)
+	# Just add the directory containing the .lo file.
+	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
+	test "X$dir" = "X$file" && dir=.
+	;;
+
+      *)
+	$echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2
+	continue
+	;;
+      esac
+
+      # Get the absolute pathname.
+      absdir=`cd "$dir" && pwd`
+      test -n "$absdir" && dir="$absdir"
+
+      # Now add the directory to shlibpath_var.
+      if eval "test -z \"\$$shlibpath_var\""; then
+	eval "$shlibpath_var=\"\$dir\""
+      else
+	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
+      fi
+    done
+
+    # This variable tells wrapper scripts just to set shlibpath_var
+    # rather than running their programs.
+    libtool_execute_magic="$magic"
+
+    # Check if any of the arguments is a wrapper script.
+    args=
+    for file
+    do
+      case $file in
+      -*) ;;
+      *)
+	# Do a test to see if this is really a libtool program.
+	if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+	  # If there is no directory component, then add one.
+	  case $file in
+	  */* | *\\*) . $file ;;
+	  *) . ./$file ;;
+	  esac
+
+	  # Transform arg to wrapped name.
+	  file="$progdir/$program"
+	fi
+	;;
+      esac
+      # Quote arguments (to preserve shell metacharacters).
+      file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"`
+      args="$args \"$file\""
+    done
+
+    if test -z "$run"; then
+      if test -n "$shlibpath_var"; then
+	# Export the shlibpath_var.
+	eval "export $shlibpath_var"
+      fi
+
+      # Restore saved enviroment variables
+      if test "${save_LC_ALL+set}" = set; then
+	LC_ALL="$save_LC_ALL"; export LC_ALL
+      fi
+      if test "${save_LANG+set}" = set; then
+	LANG="$save_LANG"; export LANG
+      fi
+
+      # Now prepare to actually exec the command.
+      exec_cmd="\$cmd$args"
+    else
+      # Display what would be done.
+      if test -n "$shlibpath_var"; then
+	eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\""
+	$echo "export $shlibpath_var"
+      fi
+      $echo "$cmd$args"
+      exit 0
+    fi
+    ;;
+
+  # libtool clean and uninstall mode
+  clean | uninstall)
+    modename="$modename: $mode"
+    rm="$nonopt"
+    files=
+    rmforce=
+    exit_status=0
+
+    # This variable tells wrapper scripts just to set variables rather
+    # than running their programs.
+    libtool_install_magic="$magic"
+
+    for arg
+    do
+      case $arg in
+      -f) rm="$rm $arg"; rmforce=yes ;;
+      -*) rm="$rm $arg" ;;
+      *) files="$files $arg" ;;
+      esac
+    done
+
+    if test -z "$rm"; then
+      $echo "$modename: you must specify an RM program" 1>&2
+      $echo "$help" 1>&2
+      exit 1
+    fi
+
+    rmdirs=
+
+    for file in $files; do
+      dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
+      if test "X$dir" = "X$file"; then
+	dir=.
+	objdir="$objdir"
+      else
+	objdir="$dir/$objdir"
+      fi
+      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
+      test "$mode" = uninstall && objdir="$dir"
+
+      # Remember objdir for removal later, being careful to avoid duplicates
+      if test "$mode" = clean; then
+	case " $rmdirs " in
+	  *" $objdir "*) ;;
+	  *) rmdirs="$rmdirs $objdir" ;;
+	esac
+      fi
+
+      # Don't error if the file doesn't exist and rm -f was used.
+      if (test -L "$file") >/dev/null 2>&1 \
+	|| (test -h "$file") >/dev/null 2>&1 \
+	|| test -f "$file"; then
+	:
+      elif test -d "$file"; then
+	exit_status=1
+	continue
+      elif test "$rmforce" = yes; then
+	continue
+      fi
+
+      rmfiles="$file"
+
+      case $name in
+      *.la)
+	# Possibly a libtool archive, so verify it.
+	if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+	  . $dir/$name
+
+	  # Delete the libtool libraries and symlinks.
+	  for n in $library_names; do
+	    rmfiles="$rmfiles $objdir/$n"
+	  done
+	  test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
+	  test "$mode" = clean && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
+
+	  if test "$mode" = uninstall; then
+	    if test -n "$library_names"; then
+	      # Do each command in the postuninstall commands.
+	      eval cmds=\"$postuninstall_cmds\"
+	      save_ifs="$IFS"; IFS='~'
+	      for cmd in $cmds; do
+		IFS="$save_ifs"
+		$show "$cmd"
+		$run eval "$cmd"
+		if test "$?" -ne 0 && test "$rmforce" != yes; then
+		  exit_status=1
+		fi
+	      done
+	      IFS="$save_ifs"
+	    fi
+
+	    if test -n "$old_library"; then
+	      # Do each command in the old_postuninstall commands.
+	      eval cmds=\"$old_postuninstall_cmds\"
+	      save_ifs="$IFS"; IFS='~'
+	      for cmd in $cmds; do
+		IFS="$save_ifs"
+		$show "$cmd"
+		$run eval "$cmd"
+		if test "$?" -ne 0 && test "$rmforce" != yes; then
+		  exit_status=1
+		fi
+	      done
+	      IFS="$save_ifs"
+	    fi
+	    # FIXME: should reinstall the best remaining shared library.
+	  fi
+	fi
+	;;
+
+      *.lo)
+	if test "$build_old_libs" = yes; then
+	  oldobj=`$echo "X$name" | $Xsed -e "$lo2o"`
+	  rmfiles="$rmfiles $dir/$oldobj"
+	fi
+	;;
+
+      *)
+	# Do a test to see if this is a libtool program.
+	if test "$mode" = clean &&
+	   (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+	  relink_command=
+	  . $dir/$file
+
+	  rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
+	  if test "$fast_install" = yes && test -n "$relink_command"; then
+	    rmfiles="$rmfiles $objdir/lt-$name"
+	  fi
+	fi
+	;;
+      esac
+      $show "$rm $rmfiles"
+      $run $rm $rmfiles || exit_status=1
+    done
+
+    # Try to remove the ${objdir}s in the directories where we deleted files
+    for dir in $rmdirs; do
+      if test -d "$dir"; then
+	$show "rmdir $dir"
+	$run rmdir $dir >/dev/null 2>&1
+      fi
+    done
+
+    exit $exit_status
+    ;;
+
+  "")
+    $echo "$modename: you must specify a MODE" 1>&2
+    $echo "$generic_help" 1>&2
+    exit 1
+    ;;
+  esac
+
+  if test -z "$exec_cmd"; then
+    $echo "$modename: invalid operation mode \`$mode'" 1>&2
+    $echo "$generic_help" 1>&2
+    exit 1
+  fi
+fi # test -z "$show_help"
+
+if test -n "$exec_cmd"; then
+  eval exec $exec_cmd
+  exit 1
+fi
+
+# We need to display help for each of the modes.
+case $mode in
+"") $echo \
+"Usage: $modename [OPTION]... [MODE-ARG]...
+
+Provide generalized library-building support services.
+
+    --config          show all configuration variables
+    --debug           enable verbose shell tracing
+-n, --dry-run         display commands without modifying any files
+    --features        display basic configuration information and exit
+    --finish          same as \`--mode=finish'
+    --help            display this help message and exit
+    --mode=MODE       use operation mode MODE [default=inferred from MODE-ARGS]
+    --quiet           same as \`--silent'
+    --silent          don't print informational messages
+    --version         print version information
+
+MODE must be one of the following:
+
+      clean           remove files from the build directory
+      compile         compile a source file into a libtool object
+      execute         automatically set library path, then run a program
+      finish          complete the installation of libtool libraries
+      install         install libraries or executables
+      link            create a library or an executable
+      uninstall       remove libraries from an installed directory
+
+MODE-ARGS vary depending on the MODE.  Try \`$modename --help --mode=MODE' for
+a more detailed description of MODE."
+  exit 0
+  ;;
+
+clean)
+  $echo \
+"Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
+
+Remove files from the build directory.
+
+RM is the name of the program to use to delete files associated with each FILE
+(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
+to RM.
+
+If FILE is a libtool library, object or program, all the files associated
+with it are deleted. Otherwise, only FILE itself is deleted using RM."
+  ;;
+
+compile)
+  $echo \
+"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
+
+Compile a source file into a libtool library object.
+
+This mode accepts the following additional options:
+
+  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
+  -prefer-pic       try to building PIC objects only
+  -prefer-non-pic   try to building non-PIC objects only
+  -static           always build a \`.o' file suitable for static linking
+
+COMPILE-COMMAND is a command to be used in creating a \`standard' object file
+from the given SOURCEFILE.
+
+The output file name is determined by removing the directory component from
+SOURCEFILE, then substituting the C source code suffix \`.c' with the
+library object suffix, \`.lo'."
+  ;;
+
+execute)
+  $echo \
+"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]...
+
+Automatically set library path, then run a program.
+
+This mode accepts the following additional options:
+
+  -dlopen FILE      add the directory containing FILE to the library path
+
+This mode sets the library path environment variable according to \`-dlopen'
+flags.
+
+If any of the ARGS are libtool executable wrappers, then they are translated
+into their corresponding uninstalled binary, and any of their required library
+directories are added to the library path.
+
+Then, COMMAND is executed, with ARGS as arguments."
+  ;;
+
+finish)
+  $echo \
+"Usage: $modename [OPTION]... --mode=finish [LIBDIR]...
+
+Complete the installation of libtool libraries.
+
+Each LIBDIR is a directory that contains libtool libraries.
+
+The commands that this mode executes may require superuser privileges.  Use
+the \`--dry-run' option if you just want to see what would be executed."
+  ;;
+
+install)
+  $echo \
+"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND...
+
+Install executables or libraries.
+
+INSTALL-COMMAND is the installation command.  The first component should be
+either the \`install' or \`cp' program.
+
+The rest of the components are interpreted as arguments to that command (only
+BSD-compatible install options are recognized)."
+  ;;
+
+link)
+  $echo \
+"Usage: $modename [OPTION]... --mode=link LINK-COMMAND...
+
+Link object files or libraries together to form another library, or to
+create an executable program.
+
+LINK-COMMAND is a command using the C compiler that you would use to create
+a program from several object files.
+
+The following components of LINK-COMMAND are treated specially:
+
+  -all-static       do not do any dynamic linking at all
+  -avoid-version    do not add a version suffix if possible
+  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
+  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
+  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
+  -export-symbols SYMFILE
+		    try to export only the symbols listed in SYMFILE
+  -export-symbols-regex REGEX
+		    try to export only the symbols matching REGEX
+  -LLIBDIR          search LIBDIR for required installed libraries
+  -lNAME            OUTPUT-FILE requires the installed library libNAME
+  -module           build a library that can dlopened
+  -no-fast-install  disable the fast-install mode
+  -no-install       link a not-installable executable
+  -no-undefined     declare that a library does not refer to external symbols
+  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
+  -release RELEASE  specify package release information
+  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
+  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
+  -static           do not do any dynamic linking of libtool libraries
+  -version-info CURRENT[:REVISION[:AGE]]
+		    specify library version info [each variable defaults to 0]
+
+All other options (arguments beginning with \`-') are ignored.
+
+Every other argument is treated as a filename.  Files ending in \`.la' are
+treated as uninstalled libtool libraries, other files are standard or library
+object files.
+
+If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
+only library objects (\`.lo' files) may be specified, and \`-rpath' is
+required, except when creating a convenience library.
+
+If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
+using \`ar' and \`ranlib', or on Windows using \`lib'.
+
+If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
+is created, otherwise an executable program is created."
+  ;;
+
+uninstall)
+  $echo \
+"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
+
+Remove libraries from an installation directory.
+
+RM is the name of the program to use to delete files associated with each FILE
+(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
+to RM.
+
+If FILE is a libtool library, all the files associated with it are deleted.
+Otherwise, only FILE itself is deleted using RM."
+  ;;
+
+*)
+  $echo "$modename: invalid operation mode \`$mode'" 1>&2
+  $echo "$help" 1>&2
+  exit 1
+  ;;
+esac
+
+echo
+$echo "Try \`$modename --help' for more information about other modes."
+
+exit 0
+
+# Local Variables:
+# mode:shell-script
+# sh-indentation:2
+# End:

Added: experimental/j/Elphel333/rtp/daemon/rtp/mbus.c
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/mbus.c	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/mbus.c	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,1030 @@
+/*
+ * FILE:     mbus.c
+ * AUTHOR:   Colin Perkins
+ * MODIFIED: Orion Hodson
+ *           Markus Germeier
+ * 
+ * Copyright (c) 1997-2000 University College London
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, is permitted provided that the following conditions 
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by the Computer Science
+ *      Department at University College London
+ * 4. Neither the name of the University nor of the Department may be used
+ *    to endorse or promote products derived from this software without
+ *    specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "config_unix.h"
+#include "config_win32.h"
+#include "debug.h"
+#include "memory.h"
+#include "net_udp.h"
+#include "hmac.h"
+#include "qfDES.h"
+#include "base64.h"
+#include "gettimeofday.h"
+#include "vsnprintf.h"
+#include "mbus.h"
+#include "mbus_config.h"
+#include "mbus_parser.h"
+#include "mbus_addr.h"
+
+#define MBUS_BUF_SIZE	  1500
+#define MBUS_ACK_BUF_SIZE 1500
+#define MBUS_MAX_ADDR	    10
+#define MBUS_MAX_QLEN	    50 /* Number of messages we can queue with mbus_qmsg() */
+
+#define MBUS_MAGIC	0x87654321
+#define MBUS_MSG_MAGIC	0x12345678
+
+struct mbus_msg {
+	struct mbus_msg	*next;
+	struct timeval	 send_time;	/* Time the message was sent, to trigger a retransmit */
+	struct timeval	 comp_time;	/* Time the message was composed, the timestamp in the packet header */
+	char		*dest;
+	int		 reliable;
+	int		 complete;	/* Indicates that we've finished adding cmds to this message */
+	int		 seqnum;
+	int		 retransmit_count;
+	int		 message_size;
+	int		 num_cmds;
+	char		*cmd_list[MBUS_MAX_QLEN];
+	char		*arg_list[MBUS_MAX_QLEN];
+	uint32_t	 idx_list[MBUS_MAX_QLEN];
+	uint32_t	 magic;		/* For debugging... */
+};
+
+struct mbus {
+	socket_udp	 	 *s;
+	char		 	 *addr;				/* Addresses we respond to. 					*/
+	int		 	  max_other_addr;
+	int		 	  num_other_addr;
+	char			**other_addr;			/* Addresses of other entities on the mbus. 			*/
+        struct timeval          **other_hello;                  /* Time of last mbus.hello we received from other entities      */
+	int		 	  seqnum;
+	struct mbus_msg	 	 *cmd_queue;			/* Queue of messages waiting to be sent */
+	struct mbus_msg	 	 *waiting_ack;			/* The last reliable message sent, if we have not yet got the ACK */
+	char		 	 *hashkey;
+	int		 	  hashkeylen;
+	char		 	 *encrkey;
+	int		 	  encrkeylen;
+	struct timeval	 	  last_heartbeat;		/* Last time we sent a heartbeat message */
+	struct mbus_config	 *cfg;
+	void (*cmd_handler)(char *src, char *cmd, char *arg, void *dat);
+	void (*err_handler)(int seqnum, int reason);
+	uint32_t		  magic;			/* For debugging...                                             */
+	uint32_t		  index;
+	uint32_t		  index_sent;
+};
+
+static void mbus_validate(struct mbus *m)
+{
+#ifdef DEBUG
+	int	i;
+
+	ASSERT(m->num_other_addr <= m->max_other_addr);
+	ASSERT(m->num_other_addr >= 0);
+	for (i = 0; i < m->num_other_addr; i++) {
+		ASSERT(m->other_addr[i]  != NULL);
+		ASSERT(m->other_hello[i] != NULL);
+	}
+	for (i = m->num_other_addr + 1; i < m->max_other_addr; i++) {
+		ASSERT(m->other_addr[i]  == NULL);
+		ASSERT(m->other_hello[i] == NULL);
+	}
+#endif
+	ASSERT(m->magic == MBUS_MAGIC);
+	xmemchk();
+}
+
+static void mbus_msg_validate(struct mbus_msg *m)
+{
+#ifdef DEBUG
+	int	i;
+
+	ASSERT((m->num_cmds < MBUS_MAX_QLEN) && (m->num_cmds >= 0));
+	for (i = 0; i < m->num_cmds; i++) {
+		ASSERT(m->cmd_list[i] != NULL);
+		ASSERT(m->arg_list[i] != NULL);
+		if (i > 0) {
+			ASSERT(m->idx_list[i] > m->idx_list[i-1]);
+		}
+	}
+	for (i = m->num_cmds + 1; i < MBUS_MAX_QLEN; i++) {
+		ASSERT(m->cmd_list[i] == NULL);
+		ASSERT(m->arg_list[i] == NULL);
+	}	
+	ASSERT(m->dest != NULL);
+#endif
+	ASSERT(m->magic == MBUS_MSG_MAGIC);
+}
+
+static void store_other_addr(struct mbus *m, char *a)
+{
+	/* This takes the address a and ensures it is stored in the   */
+	/* m->other_addr field of the mbus structure. The other_addr  */
+	/* field should probably be a hash table, but for now we hope */
+	/* that there are not too many entities on the mbus, so the   */
+	/* list is small.                                             */
+	int	i;
+
+	mbus_validate(m);
+
+	for (i = 0; i < m->num_other_addr; i++) {
+		if (mbus_addr_match(m->other_addr[i], a)) {
+			/* Already in the list... */
+			gettimeofday(m->other_hello[i],NULL);
+			return;
+		}
+	}
+
+	if (m->num_other_addr == m->max_other_addr) {
+		/* Expand the list... */
+		m->max_other_addr *= 2;
+		m->other_addr = (char **) xrealloc(m->other_addr, m->max_other_addr * sizeof(char *));
+		m->other_hello = (struct timeval **) xrealloc(m->other_hello, m->max_other_addr * sizeof(struct timeval *));
+	}
+	m->other_hello[m->num_other_addr]=(struct timeval *)xmalloc(sizeof(struct timeval));
+	gettimeofday(m->other_hello[m->num_other_addr],NULL);
+	m->other_addr[m->num_other_addr++] = xstrdup(a);
+}
+
+static void remove_other_addr(struct mbus *m, char *a)
+{
+	/* Removes the address a from the m->other_addr field of the */
+	/* mbus structure.                                           */
+	int	i, j;
+
+	mbus_validate(m);
+
+	for (i = 0; i < m->num_other_addr; i++) {
+		if (mbus_addr_match(m->other_addr[i], a)) {
+			xfree(m->other_addr[i]);
+			xfree(m->other_hello[i]);
+			for (j = i+1; j < m->num_other_addr; j++) {
+				m->other_addr[j-1] = m->other_addr[j];
+				m->other_hello[j-1] = m->other_hello[j];
+			}
+			m->other_addr[m->num_other_addr  - 1] = NULL;
+			m->other_hello[m->num_other_addr - 1] = NULL;
+			m->num_other_addr--;
+		}
+	}
+}
+
+static void remove_inactiv_other_addr(struct mbus *m, struct timeval t, int interval){
+	/* Remove addresses we haven't heard from for about 5 * interval */
+	/* Count backwards so it is safe to remove entries               */
+	int i;
+    
+	mbus_validate(m);
+
+	for (i=m->num_other_addr-1; i>=0; i--){
+#ifndef __QNXNTO__
+		if ((t.tv_sec-(m->other_hello[i]->tv_sec)) >  5 * interval) {
+#else
+		if ((t.tv_sec-(m->other_hello[i]->tv_sec)) > (unsigned int)( 5 * interval)) {
+#endif
+		debug_msg("remove dead entity (%s)\n", m->other_addr[i]);
+			remove_other_addr(m, m->other_addr[i]);
+		}
+	}
+}
+
+int mbus_addr_valid(struct mbus *m, char *addr)
+{
+	int	i;
+
+	mbus_validate(m);
+
+	for (i = 0; i < m->num_other_addr; i++) {
+		if (mbus_addr_match(m->other_addr[i], addr)) {
+			return TRUE;
+		}
+	}
+	return FALSE;
+}
+
+static int mbus_addr_unique(struct mbus *m, char *addr)
+{
+	int     i, n = 0;
+
+	mbus_validate(m);
+
+	for (i = 0; i < m->num_other_addr; i++) {
+		if (mbus_addr_match(m->other_addr[i], addr)) {
+			n++;
+		}
+	}
+	return n==1;
+}
+
+/* The mb_* functions are used to build an mbus message up in the */
+/* mb_buffer, and to add authentication and encryption before the */
+/* message is sent.                                               */
+char	 mb_cryptbuf[MBUS_BUF_SIZE];
+char	*mb_buffer;
+char	*mb_bufpos;
+
+#define MBUS_AUTH_LEN 16
+
+static void mb_header(int seqnum, int ts, char reliable, const char *src, const char *dst, int ackseq)
+{
+	xmemchk();
+	mb_buffer   = (char *) xmalloc(MBUS_BUF_SIZE + 1);
+	memset(mb_buffer,   0, MBUS_BUF_SIZE);
+	memset(mb_buffer, ' ', MBUS_AUTH_LEN);
+	mb_bufpos = mb_buffer + MBUS_AUTH_LEN;
+	sprintf(mb_bufpos, "\nmbus/1.0 %6d %9d %c (%s) %s ", seqnum, ts, reliable, src, dst);
+	mb_bufpos += 33 + strlen(src) + strlen(dst);
+	if (ackseq == -1) {
+		sprintf(mb_bufpos, "()\n");
+		mb_bufpos += 3;
+	} else {
+		sprintf(mb_bufpos, "(%6d)\n", ackseq);
+		mb_bufpos += 9;
+	}
+}
+
+static void mb_add_command(const char *cmnd, const char *args)
+{
+	int offset = strlen(cmnd) + strlen(args) + 5;
+
+	ASSERT((mb_bufpos + offset - mb_buffer) < MBUS_BUF_SIZE);
+
+	sprintf(mb_bufpos, "%s (%s)\n", cmnd, args);
+	mb_bufpos += offset - 1; /* The -1 in offset means we're not NUL terminated - fix in mb_send */
+}
+
+static void mb_send(struct mbus *m)
+{
+	char		digest[16];
+	int		len;
+	unsigned char	initVec[8] = {0,0,0,0,0,0,0,0};
+ 
+	mbus_validate(m);
+
+	*(mb_bufpos++) = '\0';
+	ASSERT((mb_bufpos - mb_buffer) < MBUS_BUF_SIZE);
+	ASSERT(strlen(mb_buffer) < MBUS_BUF_SIZE);
+
+	/* Pad to a multiple of 8 bytes, so the encryption can work... */
+	while (((mb_bufpos - mb_buffer) % 8) != 0) {
+		*(mb_bufpos++) = '\0';
+	}
+	len = mb_bufpos - mb_buffer;
+	ASSERT(len < MBUS_BUF_SIZE);
+	ASSERT(strlen(mb_buffer) < MBUS_BUF_SIZE);
+
+	xmemchk();
+	if (m->hashkey != NULL) {
+		/* Authenticate... */
+		hmac_md5(mb_buffer + MBUS_AUTH_LEN+1, strlen(mb_buffer) - (MBUS_AUTH_LEN+1), m->hashkey, m->hashkeylen, digest);
+		base64encode(digest, 12, mb_buffer, MBUS_AUTH_LEN);
+	}
+	xmemchk();
+	if (m->encrkey != NULL) {
+		/* Encrypt... */
+		memset(mb_cryptbuf, 0, MBUS_BUF_SIZE);
+		memcpy(mb_cryptbuf, mb_buffer, len);
+		ASSERT((len % 8) == 0);
+		ASSERT(len < MBUS_BUF_SIZE);
+		ASSERT(m->encrkeylen == 8);
+		xmemchk();
+		qfDES_CBC_e(m->encrkey, mb_cryptbuf, len, initVec);
+		xmemchk();
+		memcpy(mb_buffer, mb_cryptbuf, len);
+	}
+	xmemchk();
+	udp_send(m->s, mb_buffer, len);
+	xfree(mb_buffer);
+}
+
+static void resend(struct mbus *m, struct mbus_msg *curr) 
+{
+	/* Don't need to check for buffer overflows: this was done in mbus_send() when */
+	/* this message was first transmitted. If it was okay then, it's okay now.     */
+	int	 i;
+
+	mbus_validate(m);
+
+	mb_header(curr->seqnum, curr->comp_time.tv_sec, (char)(curr->reliable?'R':'U'), m->addr, curr->dest, -1);
+	for (i = 0; i < curr->num_cmds; i++) {
+		mb_add_command(curr->cmd_list[i], curr->arg_list[i]);
+	}
+	mb_send(m);
+	curr->retransmit_count++;
+}
+
+void mbus_retransmit(struct mbus *m)
+{
+	struct mbus_msg	*curr = m->waiting_ack;
+	struct timeval	time;
+	long		diff;
+
+	mbus_validate(m);
+
+	if (!mbus_waiting_ack(m)) {
+		return;
+	}
+
+	mbus_msg_validate(curr);
+
+	gettimeofday(&time, NULL);
+
+	/* diff is time in milliseconds that the message has been awaiting an ACK */
+	diff = ((time.tv_sec * 1000) + (time.tv_usec / 1000)) - ((curr->send_time.tv_sec * 1000) + (curr->send_time.tv_usec / 1000));
+	if (diff > 10000) {
+		debug_msg("Reliable mbus message failed!\n");
+		if (m->err_handler == NULL) {
+			abort();
+		}
+		m->err_handler(curr->seqnum, MBUS_MESSAGE_LOST);
+		/* if we don't delete this failed message, the error handler
+                   gets triggered every time we call mbus_retransmit */
+		while (m->waiting_ack->num_cmds > 0) {
+		    m->waiting_ack->num_cmds--;
+		    xfree(m->waiting_ack->cmd_list[m->waiting_ack->num_cmds]);
+		    xfree(m->waiting_ack->arg_list[m->waiting_ack->num_cmds]);
+		}
+		xfree(m->waiting_ack->dest);
+		xfree(m->waiting_ack);
+		m->waiting_ack = NULL;
+		return;
+	} 
+	/* Note: We only send one retransmission each time, to avoid
+	 * overflowing the receiver with a burst of requests...
+	 */
+	if ((diff > 750) && (curr->retransmit_count == 2)) {
+		resend(m, curr);
+		return;
+	} 
+	if ((diff > 500) && (curr->retransmit_count == 1)) {
+		resend(m, curr);
+		return;
+	} 
+	if ((diff > 250) && (curr->retransmit_count == 0)) {
+		resend(m, curr);
+		return;
+	}
+}
+
+void mbus_heartbeat(struct mbus *m, int interval)
+{
+	struct timeval	curr_time;
+	char	*a = (char *) xmalloc(3);
+	sprintf(a, "()");
+
+	mbus_validate(m);
+
+	gettimeofday(&curr_time, NULL);
+#ifndef __QNXNTO__
+	if (curr_time.tv_sec - m->last_heartbeat.tv_sec >= interval) {
+#else
+	if (curr_time.tv_sec - m->last_heartbeat.tv_sec >= (unsigned int)interval) {
+#endif
+		mb_header(++m->seqnum, (int) curr_time.tv_sec, 'U', m->addr, "()", -1);
+		mb_add_command("mbus.hello", "");
+		mb_send(m);
+
+		m->last_heartbeat = curr_time;
+		/* Remove dead sources */
+		remove_inactiv_other_addr(m, curr_time, interval);
+	}
+	xfree(a);
+}
+
+int mbus_waiting_ack(struct mbus *m)
+{
+	mbus_validate(m);
+	return m->waiting_ack != NULL;
+}
+
+int mbus_sent_all(struct mbus *m)
+{
+	mbus_validate(m);
+	return (m->cmd_queue == NULL) && (m->waiting_ack == NULL);
+}
+
+struct mbus *mbus_init(void  (*cmd_handler)(char *src, char *cmd, char *arg, void *dat), 
+		       void  (*err_handler)(int seqnum, int reason),
+		       char  *addr)
+{
+	struct mbus		*m;
+	struct mbus_key	 	 k;
+	struct mbus_parser	*mp;
+	int		 	 i;
+	char            	*net_addr, *tmp;
+	uint16_t         	 net_port;
+	int              	 net_scope;
+
+	m = (struct mbus *) xmalloc(sizeof(struct mbus));
+	if (m == NULL) {
+		debug_msg("Unable to allocate memory for mbus\n");
+		return NULL;
+	}
+
+	m->cfg = mbus_create_config();
+	mbus_lock_config_file(m->cfg);
+	net_addr = (char *) xmalloc(20);
+	mbus_get_net_addr(m->cfg, net_addr, &net_port, &net_scope);
+	m->s		  = udp_init(net_addr, net_port, net_port, net_scope);
+        if (m->s == NULL) {
+                debug_msg("Unable to initialize mbus address\n");
+                xfree(m);
+                return NULL;
+        }
+	m->seqnum         = 0;
+	m->cmd_handler    = cmd_handler;
+	m->err_handler	  = err_handler;
+	m->num_other_addr = 0;
+	m->max_other_addr = 10;
+	m->other_addr     = (char **) xmalloc(sizeof(char *) * 10);
+	m->other_hello    = (struct timeval **) xmalloc(sizeof(struct timeval *) * 10);
+	for (i = 0; i < 10; i++) {
+		m->other_addr[i]  = NULL;
+		m->other_hello[i] = NULL;
+	}
+	m->cmd_queue	  = NULL;
+	m->waiting_ack	  = NULL;
+	m->magic          = MBUS_MAGIC;
+	m->index          = 0;
+	m->index_sent     = 0;
+
+	mp = mbus_parse_init(xstrdup(addr));
+	if (!mbus_parse_lst(mp, &tmp)) {
+		debug_msg("Invalid mbus address\n");
+		abort();
+	}
+	m->addr = xstrdup(tmp);
+	mbus_parse_done(mp);
+	ASSERT(m->addr != NULL);
+
+	gettimeofday(&(m->last_heartbeat), NULL);
+
+	mbus_get_encrkey(m->cfg, &k);
+	m->encrkey    = k.key;
+	m->encrkeylen = k.key_len;
+
+	mbus_get_hashkey(m->cfg, &k);
+	m->hashkey    = k.key;
+	m->hashkeylen = k.key_len;
+
+	mbus_unlock_config_file(m->cfg);
+
+	xfree(net_addr);
+
+	return m;
+}
+
+void mbus_cmd_handler(struct mbus *m, void  (*cmd_handler)(char *src, char *cmd, char *arg, void *dat))
+{
+	mbus_validate(m);
+	m->cmd_handler = cmd_handler;
+}
+
+static void mbus_flush_msgs(struct mbus_msg **queue)
+{
+        struct mbus_msg *curr, *next;
+        int i;
+	
+        curr = *queue;
+        while(curr) {
+                next = curr->next;
+                xfree(curr->dest);
+                for(i = 0; i < curr->num_cmds; i++) {
+                        xfree(curr->cmd_list[i]);
+                        xfree(curr->arg_list[i]);
+                }
+		xfree(curr);
+                curr = next;
+        }
+	*queue = NULL;
+}
+
+void mbus_exit(struct mbus *m) 
+{
+        int i;
+
+        ASSERT(m != NULL);
+	mbus_validate(m);
+
+	mbus_qmsg(m, "()", "mbus.bye", "", FALSE);
+	mbus_send(m);
+
+	/* FIXME: It should be a fatal error to call mbus_exit() if some messages are still outstanding. */
+	/*        We will need an mbus_flush() call first though, to ensure nothing is waiting.          */
+        mbus_flush_msgs(&m->cmd_queue);
+        mbus_flush_msgs(&m->waiting_ack);
+
+        if (m->encrkey != NULL) {
+                xfree(m->encrkey);
+        }
+        if (m->hashkey != NULL) {
+        	xfree(m->hashkey);
+	}
+
+        udp_exit(m->s);
+
+	/* Clean up other_* */
+	for (i=m->num_other_addr-1; i>=0; i--){
+	    remove_other_addr(m, m->other_addr[i]);
+	}
+
+        xfree(m->addr);
+	xfree(m->other_addr);
+	xfree(m->other_hello);
+	xfree(m->cfg);
+        xfree(m);
+}
+
+void mbus_send(struct mbus *m)
+{
+	/* Send one, or more, messages previosly queued with mbus_qmsg(). */
+	/* Messages for the same destination are batched together. Stops  */
+	/* when a reliable message is sent, until the ACK is received.    */
+	struct mbus_msg	*curr = m->cmd_queue;
+	int		 i;
+
+	mbus_validate(m);
+	if (m->waiting_ack != NULL) {
+		return;
+	}
+
+	while (curr != NULL) {
+		mbus_msg_validate(curr);
+		/* It's okay for us to send messages which haven't been marked as complete - */
+		/* that just means we're sending something which has the potential to have   */
+		/* more data piggybacked. However, if it's not complete it MUST be the last  */
+		/* in the list, or something has been reordered - which is bad.              */
+		if (!curr->complete) {
+			ASSERT(curr->next == NULL);
+		}
+
+		if (curr->reliable) {
+		        if (!mbus_addr_valid(m, curr->dest)) {
+			    debug_msg("Trying to send reliably to an unknown address...\n");
+			    if (m->err_handler == NULL) {
+				abort();
+			    }
+			    m->err_handler(curr->seqnum, MBUS_DESTINATION_UNKNOWN);
+			}
+		        if (!mbus_addr_unique(m, curr->dest)) {
+			    debug_msg("Trying to send reliably but address is not unique...\n");
+			    if (m->err_handler == NULL) {
+				abort();
+			    }
+			    m->err_handler(curr->seqnum, MBUS_DESTINATION_NOT_UNIQUE);
+			}
+		}
+		/* Create the message... */
+		mb_header(curr->seqnum, curr->comp_time.tv_sec, (char)(curr->reliable?'R':'U'), m->addr, curr->dest, -1);
+		for (i = 0; i < curr->num_cmds; i++) {
+			ASSERT(m->index_sent == (curr->idx_list[i] - 1));
+			m->index_sent = curr->idx_list[i];
+			mb_add_command(curr->cmd_list[i], curr->arg_list[i]);
+		}
+		mb_send(m);
+		
+		m->cmd_queue = curr->next;
+		if (curr->reliable) {
+			/* Reliable message, wait for the ack... */
+			gettimeofday(&(curr->send_time), NULL);
+			m->waiting_ack = curr;
+			curr->next = NULL;
+			return;
+		} else {
+			while (curr->num_cmds > 0) {
+				curr->num_cmds--;
+				xfree(curr->cmd_list[curr->num_cmds]); curr->cmd_list[curr->num_cmds] = NULL;
+				xfree(curr->arg_list[curr->num_cmds]); curr->arg_list[curr->num_cmds] = NULL;
+			}
+			xfree(curr->dest);
+			xfree(curr);
+		}
+		curr = m->cmd_queue;
+	}
+}
+
+void mbus_qmsg(struct mbus *m, const char *dest, const char *cmnd, const char *args, int reliable)
+{
+	/* Queue up a message for sending. The message is not */
+	/* actually sent until mbus_send() is called.         */
+	struct mbus_msg	*curr = m->cmd_queue;
+	struct mbus_msg	*prev = NULL;
+	int		 alen = strlen(cmnd) + strlen(args) + 4;
+	int		 i;
+
+	mbus_validate(m);
+	while (curr != NULL) {
+		mbus_msg_validate(curr);
+		if (!curr->complete) {
+			/* This message is still open for new commands. It MUST be the last in the */
+			/* cmd_queue, else commands will be reordered.                             */
+			ASSERT(curr->next == NULL);
+			if (mbus_addr_identical(curr->dest, dest) &&
+		            (curr->num_cmds < MBUS_MAX_QLEN) && ((curr->message_size + alen) < (MBUS_BUF_SIZE - 500))) {
+				curr->num_cmds++;
+				curr->reliable |= reliable;
+				curr->cmd_list[curr->num_cmds-1] = xstrdup(cmnd);
+				curr->arg_list[curr->num_cmds-1] = xstrdup(args);
+				curr->idx_list[curr->num_cmds-1] = ++(m->index);
+				curr->message_size += alen;
+				mbus_msg_validate(curr);
+				return;
+			} else {
+				curr->complete = TRUE;
+			}
+		}
+		prev = curr;
+		curr = curr->next;
+	}
+	/* If we get here, we've not found an open message in the cmd_queue.  We */
+	/* have to create a new message, and add it to the end of the cmd_queue. */
+	curr = (struct mbus_msg *) xmalloc(sizeof(struct mbus_msg));
+	curr->magic            = MBUS_MSG_MAGIC;
+	curr->next             = NULL;
+	curr->dest             = xstrdup(dest);
+	curr->retransmit_count = 0;
+	curr->message_size     = alen + 60 + strlen(dest) + strlen(m->addr);
+	curr->seqnum           = ++m->seqnum;
+	curr->reliable         = reliable;
+	curr->complete         = FALSE;
+	curr->num_cmds         = 1;
+	curr->cmd_list[0]      = xstrdup(cmnd);
+	curr->arg_list[0]      = xstrdup(args);
+	curr->idx_list[curr->num_cmds-1] = ++(m->index);
+	for (i = 1; i < MBUS_MAX_QLEN; i++) {
+		curr->cmd_list[i] = NULL;
+		curr->arg_list[i] = NULL;
+	}
+	if (prev == NULL) {
+		m->cmd_queue = curr;
+	} else {
+		prev->next = curr;
+	}
+	gettimeofday(&(curr->send_time), NULL);
+	gettimeofday(&(curr->comp_time), NULL);
+	mbus_msg_validate(curr);
+}
+
+#define mbus_qmsgf(m, dest, reliable, cmnd, format, var) \
+{ \
+char buffer[MBUS_BUF_SIZE]; \
+mbus_validate(m); \
+snprintf(buffer, MBUS_BUF_SIZE, format, var); \
+mbus_qmsg(m, dest, cmnd, buffer, reliable); \
+}
+
+#if 0
+void mbus_qmsgf(struct mbus *m, const char *dest, int reliable, const char *cmnd, const char *format, ...)
+{
+	/* This is a wrapper around mbus_qmsg() which does a printf() style format into  */
+	/* a buffer. Saves the caller from having to a a malloc(), write the args string */
+	/* and then do a free(), and also saves worring about overflowing the buffer, so */
+	/* removing a common source of bugs!                                             */
+	char	buffer[MBUS_BUF_SIZE];
+	va_list	ap;
+
+	mbus_validate(m);
+	va_start(ap, format);
+#ifdef WIN32
+        _vsnprintf(buffer, MBUS_BUF_SIZE, format, ap);
+#else
+        vsnprintf(buffer, MBUS_BUF_SIZE, format, ap);
+#endif
+	va_end(ap);
+	mbus_qmsg(m, dest, cmnd, buffer, reliable);
+}
+#endif
+
+int mbus_recv(struct mbus *m, void *data, struct timeval *timeout)
+{
+	char			*auth, *ver, *src, *dst, *ack, *r, *cmd, *param, *npos;
+	char	 		 buffer[MBUS_BUF_SIZE];
+	int	 		 buffer_len, seq, a, rx, ts, authlen, loop_count;
+	char	 		 ackbuf[MBUS_ACK_BUF_SIZE];
+	char	 		 digest[16];
+	unsigned char		 initVec[8] = {0,0,0,0,0,0,0,0};
+	struct timeval		 t;
+	struct mbus_parser	*mp, *mp2;
+
+	mbus_validate(m);
+
+	rx = FALSE;
+	loop_count = 0;
+	while (loop_count++ < 10) {
+		memset(buffer, 0, MBUS_BUF_SIZE);
+                ASSERT(m->s != NULL);
+		udp_fd_zero();
+		udp_fd_set(m->s);
+		t.tv_sec  = timeout->tv_sec;
+		t.tv_usec = timeout->tv_usec;
+                if ((udp_select(&t) > 0) && udp_fd_isset(m->s)) {
+			buffer_len = udp_recv(m->s, buffer, MBUS_BUF_SIZE);
+			if (buffer_len > 0) {
+				rx = TRUE;
+			} else {
+				return rx;
+			}
+		} else {
+			return FALSE;
+		}
+
+		if (m->encrkey != NULL) {
+			/* Decrypt the message... */
+			if ((buffer_len % 8) != 0) {
+				debug_msg("Encrypted message not a multiple of 8 bytes in length\n");
+				continue;
+			}
+			memcpy(mb_cryptbuf, buffer, buffer_len);
+			memset(initVec, 0, 8);
+			qfDES_CBC_d(m->encrkey, mb_cryptbuf, buffer_len, initVec);
+			memcpy(buffer, mb_cryptbuf, buffer_len);
+		}
+
+		/* Sanity check that this is a vaguely sensible format message... Should prevent */
+		/* problems if we're fed complete garbage, but won't prevent determined hackers. */
+		if (strncmp(buffer + MBUS_AUTH_LEN + 1, "mbus/1.0", 8) != 0) {
+			continue;
+		}
+
+		mp = mbus_parse_init(buffer);
+		/* remove trailing 0 bytes */
+		npos = (char *) strchr(buffer,'\0');
+		if(npos!=NULL) {
+			buffer_len=npos-buffer;
+		}
+		/* Parse the authentication header */
+		if (!mbus_parse_sym(mp, &auth)) {
+			debug_msg("Failed to parse authentication header\n");
+			mbus_parse_done(mp);
+			continue;
+		}
+
+		/* Check that the packet authenticates correctly... */
+		authlen = strlen(auth);
+		hmac_md5(buffer + authlen + 1, buffer_len - authlen - 1, m->hashkey, m->hashkeylen, digest);
+		base64encode(digest, 12, ackbuf, 16);
+		if ((strlen(auth) != 16) || (strncmp(auth, ackbuf, 16) != 0)) {
+			debug_msg("Failed to authenticate message...\n");
+			mbus_parse_done(mp);
+			continue;
+		}
+
+		/* Parse the header */
+		if (!mbus_parse_sym(mp, &ver)) {
+			mbus_parse_done(mp);
+			debug_msg("Parser failed version (1): %s\n",ver);
+			continue;
+		}
+		if (strcmp(ver, "mbus/1.0") != 0) {
+			mbus_parse_done(mp);
+			debug_msg("Parser failed version (2): %s\n",ver);
+			continue;
+		}
+		if (!mbus_parse_int(mp, &seq)) {
+			mbus_parse_done(mp);
+			debug_msg("Parser failed seq\n");
+			continue;
+		}
+		if (!mbus_parse_int(mp, &ts)) {
+			mbus_parse_done(mp);
+			debug_msg("Parser failed ts\n");
+			continue;
+		}
+		if (!mbus_parse_sym(mp, &r)) {
+			mbus_parse_done(mp);
+			debug_msg("Parser failed reliable\n");
+			continue;
+		}
+		if (!mbus_parse_lst(mp, &src)) {
+			mbus_parse_done(mp);
+			debug_msg("Parser failed src\n");
+			continue;
+		}
+		if (!mbus_parse_lst(mp, &dst)) {
+			mbus_parse_done(mp);
+			debug_msg("Parser failed dst\n");
+			continue;
+		}
+		if (!mbus_parse_lst(mp, &ack)) {
+			mbus_parse_done(mp);
+			debug_msg("Parser failed ack\n");
+			continue;
+		}
+
+		store_other_addr(m, src);
+
+		/* Check if the message was addressed to us... */
+		if (mbus_addr_match(m->addr, dst)) {
+			/* ...if so, process any ACKs received... */
+			mp2 = mbus_parse_init(ack);
+			while (mbus_parse_int(mp2, &a)) {
+				if (mbus_waiting_ack(m)) {
+					if (m->waiting_ack->seqnum == a) {
+						while (m->waiting_ack->num_cmds > 0) {
+							m->waiting_ack->num_cmds--;
+							xfree(m->waiting_ack->cmd_list[m->waiting_ack->num_cmds]);
+							xfree(m->waiting_ack->arg_list[m->waiting_ack->num_cmds]);
+						}
+						xfree(m->waiting_ack->dest);
+						xfree(m->waiting_ack);
+						m->waiting_ack = NULL;
+					} else {
+						debug_msg("Got ACK %d but wanted %d\n", a, m->waiting_ack->seqnum);
+					}
+				} else {
+					debug_msg("Got ACK %d but wasn't expecting it\n", a);
+				}
+			}
+			mbus_parse_done(mp2);
+			/* ...if an ACK was requested, send one... */
+			if (strcmp(r, "R") == 0) {
+				char 		*newsrc = (char *) xmalloc(strlen(src) + 3);
+				struct timeval	 t;
+
+				sprintf(newsrc, "(%s)", src);	/* Yes, this is a kludge. */
+				gettimeofday(&t, NULL);
+				mb_header(++m->seqnum, (int) t.tv_sec, 'U', m->addr, newsrc, seq);
+				mb_send(m);
+				xfree(newsrc);
+			} else if (strcmp(r, "U") == 0) {
+				/* Unreliable message.... not need to do anything */
+			} else {
+				debug_msg("Message with invalid reliability field \"%s\" ignored\n", r);
+			}
+			/* ...and process the commands contained in the message */
+			while (mbus_parse_sym(mp, &cmd)) {
+				if (mbus_parse_lst(mp, &param)) {
+					char 		*newsrc = (char *) xmalloc(strlen(src) + 3);
+					sprintf(newsrc, "(%s)", src);	/* Yes, this is a kludge. */
+					/* Finally, we snoop on the message we just passed to the application, */
+					/* to do housekeeping of our list of known mbus sources...             */
+					if (strcmp(cmd, "mbus.bye") == 0) {
+						remove_other_addr(m, newsrc);
+					} 
+					if (strcmp(cmd, "mbus.hello") == 0) {
+						/* Mark this source as activ. We remove dead sources in mbus_heartbeat */
+						store_other_addr(m, newsrc);
+					}
+					m->cmd_handler(newsrc, cmd, param, data);
+					xfree(newsrc);
+				} else {
+					debug_msg("Unable to parse mbus command:\n");
+					debug_msg("cmd = %s\n", cmd);
+					debug_msg("arg = %s\n", param);
+					break;
+				}
+			}
+		}
+		mbus_parse_done(mp);
+	}
+	return rx;
+}
+
+#define RZ_HANDLE_WAITING 1
+#define RZ_HANDLE_GO      2
+
+struct mbus_rz {
+	char		*peer;
+	char		*token;
+	struct mbus	*m;
+	void		*data;
+	int		 mode;
+	void (*cmd_handler)(char *src, char *cmd, char *args, void *data);
+};
+
+static void rz_handler(char *src, char *cmd, char *args, void *data)
+{
+	struct mbus_rz		*r = (struct mbus_rz *) data;
+	struct mbus_parser	*mp;
+
+	if ((r->mode == RZ_HANDLE_WAITING) && (strcmp(cmd, "mbus.waiting") == 0)) {
+		char	*t;
+
+		mp = mbus_parse_init(args);
+		mbus_parse_str(mp, &t);
+		if (strcmp(mbus_decode_str(t), r->token) == 0) {
+                        if (r->peer != NULL) xfree(r->peer);
+			r->peer = xstrdup(src);
+		}
+		mbus_parse_done(mp);
+	} else if ((r->mode == RZ_HANDLE_GO) && (strcmp(cmd, "mbus.go") == 0)) {
+		char	*t;
+
+		mp = mbus_parse_init(args);
+		mbus_parse_str(mp, &t);
+		if (strcmp(mbus_decode_str(t), r->token) == 0) {
+                        if (r->peer != NULL) xfree(r->peer);
+			r->peer = xstrdup(src);
+		}
+		mbus_parse_done(mp);
+	} else {
+		r->cmd_handler(src, cmd, args, r->data);
+	}
+}
+
+char *mbus_rendezvous_waiting(struct mbus *m, char *addr, char *token, void *data)
+{
+	/* Loop, sending mbus.waiting(token) to "addr", until we get mbus.go(token) */
+	/* back from our peer. Any other mbus commands received whilst waiting are  */
+	/* processed in the normal manner, as if mbus_recv() had been called.       */
+	char		*token_e, *peer;
+	struct timeval	 timeout;
+	struct mbus_rz	*r;
+
+	mbus_validate(m);
+
+	r = (struct mbus_rz *) xmalloc(sizeof(struct mbus_rz));
+	r->peer        = NULL;
+	r->token       = token;
+	r->m           = m;
+	r->data        = data;
+	r->mode        = RZ_HANDLE_GO;
+	r->cmd_handler = m->cmd_handler;
+	m->cmd_handler = rz_handler;
+	token_e        = mbus_encode_str(token);
+	while (r->peer == NULL) {
+		timeout.tv_sec  = 0;
+		timeout.tv_usec = 100000;
+		mbus_heartbeat(m, 1);
+		mbus_qmsgf(m, addr, FALSE, "mbus.waiting", "%s", token_e);
+		mbus_send(m);
+		mbus_recv(m, r, &timeout);
+		mbus_retransmit(m);
+	}
+	m->cmd_handler = r->cmd_handler;
+	peer = r->peer;
+	xfree(r);
+	xfree(token_e);
+	return peer;
+}
+
+char *mbus_rendezvous_go(struct mbus *m, char *token, void *data)
+{
+	/* Wait until we receive mbus.waiting(token), then send mbus.go(token) back to   */
+	/* the sender of that message. Whilst waiting, other mbus commands are processed */
+	/* in the normal manner as if mbus_recv() had been called.                       */
+	char		*token_e, *peer;
+	struct timeval	 timeout;
+	struct mbus_rz	*r;
+
+	mbus_validate(m);
+
+	r = (struct mbus_rz *) xmalloc(sizeof(struct mbus_rz));
+	r->peer        = NULL;
+	r->token       = token;
+	r->m           = m;
+	r->data        = data;
+	r->mode        = RZ_HANDLE_WAITING;
+	r->cmd_handler = m->cmd_handler;
+	m->cmd_handler = rz_handler;
+	token_e        = mbus_encode_str(token);
+	while (r->peer == NULL) {
+		timeout.tv_sec  = 0;
+		timeout.tv_usec = 100000;
+		mbus_heartbeat(m, 1);
+		mbus_send(m);
+		mbus_recv(m, r, &timeout);
+		mbus_retransmit(m);
+	}
+
+	mbus_qmsgf(m, r->peer, TRUE, "mbus.go", "%s", token_e);
+	do {
+		mbus_heartbeat(m, 1);
+		mbus_retransmit(m);
+		mbus_send(m);
+		timeout.tv_sec  = 0;
+		timeout.tv_usec = 100000;
+		mbus_recv(m, r, &timeout);
+	} while (!mbus_sent_all(m));
+
+	m->cmd_handler = r->cmd_handler;
+	peer = r->peer;
+	xfree(r);
+	xfree(token_e);
+	return peer;
+}
+

Added: experimental/j/Elphel333/rtp/daemon/rtp/mbus.h
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/mbus.h	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/mbus.h	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,70 @@
+/*
+ * FILE:    mbus.h
+ * AUTHORS: Colin Perkins
+ * 
+ * Copyright (c) 1997-2000 University College London
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, is permitted, provided that the following conditions 
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by the Computer Science
+ *      Department at University College London
+ * 4. Neither the name of the University nor of the Department may be used
+ *    to endorse or promote products derived from this software without
+ *    specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _MBUS_H
+#define _MBUS_H
+
+/* Error codes... */
+#define MBUS_MESSAGE_LOST           1
+#define MBUS_DESTINATION_UNKNOWN    2
+#define MBUS_DESTINATION_NOT_UNIQUE 3
+
+struct mbus;
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+struct mbus *mbus_init(void  (*cmd_handler)(char *src, char *cmd, char *arg, void *dat), 
+		       void  (*err_handler)(int seqnum, int reason),
+		       char  *addr);
+void         mbus_cmd_handler(struct mbus *m, void  (*cmd_handler)(char *src, char *cmd, char *arg, void *dat));
+void         mbus_exit(struct mbus *m);
+int          mbus_addr_valid(struct mbus *m, char *addr);
+void         mbus_qmsg(struct mbus *m, const char *dest, const char *cmnd, const char *args, int reliable);
+void         mbus_send(struct mbus *m);
+int          mbus_recv(struct mbus *m, void *data, struct timeval *timeout);
+void         mbus_retransmit(struct mbus *m);
+void         mbus_heartbeat(struct mbus *m, int interval);
+int          mbus_waiting_ack(struct mbus *m);
+int          mbus_sent_all(struct mbus *m);
+char        *mbus_rendezvous_waiting(struct mbus *m, char *addr, char *token, void *data);
+char        *mbus_rendezvous_go(struct mbus *m, char *token, void *data);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif

Added: experimental/j/Elphel333/rtp/daemon/rtp/mbus_addr.c
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/mbus_addr.c	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/mbus_addr.c	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,82 @@
+/*
+ * FILE:     mbus_addr.c
+ * AUTHOR:   Colin Perkins
+ * 
+ * Copyright (c) 2000 University College London
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, is permitted provided that the following conditions 
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by the Computer Science
+ *      Department at University College London
+ * 4. Neither the name of the University nor of the Department may be used
+ *    to endorse or promote products derived from this software without
+ *    specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "config_unix.h"
+#include "config_win32.h"
+#include "debug.h"
+#include "util.h"
+#include "mbus_addr.h"
+
+int mbus_addr_match(const char *a, const char *b)
+{
+	/* Compare the addresses "a" and "b". These may optionally be */
+	/* surrounded by "(" and ")" and may have an arbitrary amount */
+	/* of white space between components of the addresses. There  */
+	/* is a match if every word of address b is in address a.     */
+	const char	*y = NULL; 
+
+	ASSERT(a != NULL);
+	ASSERT(b != NULL);
+
+	/* Skip leading whitespace and '('... */
+	while (isspace((unsigned char)*a) || (*a == '(')) a++;
+	while (isspace((unsigned char)*b) || (*b == '(')) b++;
+
+	while ((*b != '\0') && (*b != ')')) {
+		/* Move b along through the string to the start of the next */
+		/* word. Move y along from that to the end of the word.     */
+		while (isspace((unsigned char)*b)) b++;
+		for (y = b; ((*y != ' ') && (*y != ')') && (*y != '\0')); y++) {
+			/* do nothing */
+		}
+		y--;
+		/* Check if the word between b and y is contained in the    */
+		/* string pointed to be a.                                  */
+		if (!strfind(a, b, y)) {
+			return FALSE;
+		}
+		b = ++y;
+	}		
+	return TRUE;
+}
+
+int mbus_addr_identical(const char *a, const char *b)
+{
+	/* A more restrictive version of mbus_addr_match. Returns TRUE  */
+	/* iff the addresses are identical (except, possibly, for order */
+	/* of the elements.                                             */
+	return mbus_addr_match(a, b) && mbus_addr_match(b, a);
+}
+

Added: experimental/j/Elphel333/rtp/daemon/rtp/mbus_addr.h
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/mbus_addr.h	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/mbus_addr.h	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,39 @@
+/*
+ * FILE:     mbus_addr.h
+ * AUTHOR:   Colin Perkins
+ * 
+ * Copyright (c) 2000 University College London
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, is permitted provided that the following conditions 
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by the Computer Science
+ *      Department at University College London
+ * 4. Neither the name of the University nor of the Department may be used
+ *    to endorse or promote products derived from this software without
+ *    specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+int     mbus_addr_match(const char *a, const char *b);
+int mbus_addr_identical(const char *a, const char *b);
+
+

Added: experimental/j/Elphel333/rtp/daemon/rtp/mbus_config.c
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/mbus_config.c	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/mbus_config.c	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,752 @@
+/*
+ * FILE:     mbus_config.c
+ * AUTHOR:   Colin Perkins
+ * MODIFIED: Orion Hodson
+ *           Markus Germeier
+ * 
+ * Copyright (c) 1999-2001 University College London
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, is permitted provided that the following conditions 
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by the Computer Science
+ *      Department at University College London
+ * 4. Neither the name of the University nor of the Department may be used
+ *    to endorse or promote products derived from this software without
+ *    specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "config_unix.h"
+#include "config_win32.h"
+#include "debug.h"
+#include "memory.h"
+#include "crypt_random.h"
+#include "base64.h"
+#include "mbus.h"
+#include "mbus_config.h"
+
+#define MBUS_ENCRYPT_BY_DEFAULT
+#define MBUS_ENCRKEY_LEN      8
+#define MBUS_HASHKEY_LEN     12
+#define MBUS_BUF_SIZE	   1500
+#define MBUS_FILE_NAME   ".mbus"
+#define MBUS_FILE_NAME_LEN    5
+
+struct mbus_config {
+#ifdef WIN32
+	HKEY		  cfgKey;
+#else
+	fd_t		  cfgfd;
+#endif
+	int		  cfg_locked;
+};
+
+char *mbus_new_encrkey(void)
+{
+	char		*key;	/* The key we are going to return... */
+#ifdef MBUS_ENCRYPT_BY_DEFAULT
+	/* Create a new key, for use by the hashing routines. Returns */
+	/* a key of the form (DES,MTIzMTU2MTg5MTEyMQ==)               */
+	char		 random_string[MBUS_ENCRKEY_LEN];
+	char		 encoded_string[(MBUS_ENCRKEY_LEN*4/3)+4];
+	int		 encoded_length;
+	int		 i, j, k;
+
+	/* Step 1: generate a random string for the key... */
+	for (i = 0; i < MBUS_ENCRKEY_LEN; i++) {
+		random_string[i] = ((int32_t)lbl_random() | 0x000ff000) >> 24;
+	}
+
+	/* Step 2: fill in parity bits to make DES library happy */
+	for (i = 0; i < MBUS_ENCRKEY_LEN; ++i) {
+	        k = random_string[i] & 0xfe;
+		j = k;
+		j ^= j >> 4;
+		j ^= j >> 2;
+		j ^= j >> 1;
+		j = (j & 1) ^ 1;
+		random_string[i] = k | j;
+	}
+
+	/* Step 3: base64 encode that string... */
+	memset(encoded_string, 0, (MBUS_ENCRKEY_LEN*4/3)+4);
+	encoded_length = base64encode(random_string, MBUS_ENCRKEY_LEN, encoded_string, (MBUS_ENCRKEY_LEN*4/3)+4);
+
+	/* Step 4: put it all together to produce the key... */
+	key = (char *) xmalloc(encoded_length + 18);
+	sprintf(key, "(DES,%s)", encoded_string);
+#else
+	key = (char *) xmalloc(9);
+	sprintf(key, "(NOENCR)");
+#endif
+	return key;
+}
+
+char *mbus_new_hashkey(void)
+{
+	/* Create a new key, for use by the hashing routines. Returns  */
+	/* a key of the form (HMAC-MD5-96,MTIzMTU2MTg5MTEyMQ==)           */
+	char		 random_string[MBUS_HASHKEY_LEN];
+	char		 encoded_string[(MBUS_HASHKEY_LEN*4/3)+4];
+	int		 encoded_length;
+	int		 i;
+	char		*key;
+
+	/* Step 1: generate a random string for the key... */
+	for (i = 0; i < MBUS_HASHKEY_LEN; i++) {
+		random_string[i] = ((int32_t)lbl_random() | 0x000ff000) >> 24;
+	}
+	/* Step 2: base64 encode that string... */
+	memset(encoded_string, 0, (MBUS_HASHKEY_LEN*4/3)+4);
+	encoded_length = base64encode(random_string, MBUS_HASHKEY_LEN, encoded_string, (MBUS_HASHKEY_LEN*4/3)+4);
+
+	/* Step 3: put it all together to produce the key... */
+	key = (char *) xmalloc(encoded_length + 26);
+	sprintf(key, "(HMAC-MD5-96,%s)", encoded_string);
+
+	return key;
+}
+
+static void rewrite_config(struct mbus_config *m)
+{
+#ifdef WIN32
+	char		*hashkey = mbus_new_hashkey();
+	char		*encrkey = mbus_new_encrkey();
+	char		*scope   = MBUS_DEFAULT_SCOPE_NAME;
+	const uint32_t	 cver    = MBUS_CONFIG_VERSION;
+	const uint32_t	 port    = MBUS_DEFAULT_NET_PORT;
+	char		*addr    = xstrdup(MBUS_DEFAULT_NET_ADDR);
+	char		 buffer[MBUS_BUF_SIZE];
+	LONG		 status;
+
+	status = RegSetValueEx(m->cfgKey, "CONFIG_VERSION", 0, REG_DWORD, (const uint8_t *) &cver, sizeof(cver));
+	if (status != ERROR_SUCCESS) {
+		FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, status, 0, buffer, MBUS_BUF_SIZE, NULL);
+		debug_msg("Unable to set version: %s\n", buffer);
+		abort();
+	}
+	status = RegSetValueEx(m->cfgKey, "HASHKEY", 0, REG_SZ, hashkey, strlen(hashkey) + 1);
+	if (status != ERROR_SUCCESS) {
+		FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, status, 0, buffer, MBUS_BUF_SIZE, NULL);
+		debug_msg("Unable to set hashkey: %s\n", buffer);
+		abort();
+	}	
+	status = RegSetValueEx(m->cfgKey, "ENCRYPTIONKEY", 0, REG_SZ, encrkey, strlen(encrkey) + 1);
+	if (status != ERROR_SUCCESS) {
+		FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, status, 0, buffer, MBUS_BUF_SIZE, NULL);
+		debug_msg("Unable to set encrkey: %s\n", buffer);
+		abort();
+	}	
+	status = RegSetValueEx(m->cfgKey, "SCOPE", 0, REG_SZ, scope, strlen(scope) + 1);
+	if (status != ERROR_SUCCESS) {
+		FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, status, 0, buffer, MBUS_BUF_SIZE, NULL);
+		debug_msg("Unable to set scope: %s\n", buffer);
+		abort();
+	}	
+	status = RegSetValueEx(m->cfgKey, "ADDRESS", 0, REG_SZ, addr, strlen(addr) + 1);
+	if (status != ERROR_SUCCESS) {
+		FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, status, 0, buffer, MBUS_BUF_SIZE, NULL);
+		debug_msg("Unable to set address: %s\n", buffer);
+		abort();
+	}	
+	status = RegSetValueEx(m->cfgKey, "PORT", 0, REG_DWORD, (const uint8_t *) &port, sizeof(port));
+	if (status != ERROR_SUCCESS) {
+		FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, status, 0, buffer, MBUS_BUF_SIZE, NULL);
+		debug_msg("Unable to set port: %s\n", buffer);
+		abort();
+	}	
+	xfree(addr);
+#else
+	char	*hashkey = mbus_new_hashkey();
+	char	*encrkey = mbus_new_encrkey();
+	char	 buf[1024];
+
+	if (lseek(m->cfgfd, 0, SEEK_SET) == -1) {
+		perror("Can't seek to start of config file");
+		abort();
+	}
+	sprintf(buf, "[MBUS]\nCONFIG_VERSION=%d\nHASHKEY=%s\nENCRYPTIONKEY=%s\nSCOPE=%s\nADDRESS=%s\nPORT=%d\n", 
+		MBUS_CONFIG_VERSION, hashkey, encrkey, MBUS_DEFAULT_SCOPE_NAME, MBUS_DEFAULT_NET_ADDR, MBUS_DEFAULT_NET_PORT);
+	write(m->cfgfd, buf, strlen(buf));
+	free(hashkey);
+	xfree(encrkey);
+#endif
+}
+
+void mbus_lock_config_file(struct mbus_config *m)
+{
+#ifdef WIN32
+	/* Open the registry and create the mbus entries if they don't exist   */
+	/* already. The default contents of the registry are random encryption */
+	/* and authentication keys, and node local scope.                      */
+	HKEY			key    = HKEY_CURRENT_USER;
+	LPCTSTR			subKey = "Software\\Mbone Applications\\mbus";
+	DWORD			disp;
+	char			buffer[MBUS_BUF_SIZE];
+	LONG			status;
+
+	status = RegCreateKeyEx(key, subKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &(m->cfgKey), &disp);
+	if (status != ERROR_SUCCESS) {
+		FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, status, 0, buffer, MBUS_BUF_SIZE, NULL);
+		debug_msg("Unable to open registry: %s\n", buffer);
+		abort();
+	}
+	if (disp == REG_CREATED_NEW_KEY) {
+		rewrite_config(m);
+		debug_msg("Created new registry entry...\n");
+	} else {
+		debug_msg("Opened existing registry entry...\n");
+	}
+#else
+	/* Obtain a valid lock on the mbus configuration file. This function */
+	/* creates the file, if one does not exist. The default contents of  */
+	/* this file are random authentication and encryption keys, and node */
+	/* local scope.                                                      */
+	struct flock	 l;
+	struct stat	 s;
+	char		*buf;
+	char		*cfg_file;
+	char            *cfg_loc;
+	int              cfg_loc_len;
+
+	cfg_loc = getenv("MBUS");
+	if (cfg_loc == NULL) {
+                cfg_loc = getenv("HOME");
+                if (cfg_loc == NULL) {
+                        /* The getpwuid() stuff is to determine the users    */
+                        /* home directory, into which we write a .mbus       */
+                        /* config file. The struct returned by getpwuid() is */
+                        /* statically allocated, so it's not necessary to    */
+                        /* free it afterwards.                               */
+                        struct passwd	*p;	
+                        p = getpwuid(getuid());
+                        if (p == NULL) {
+                                perror("Unable to get passwd entry");
+                                abort();	      
+                        }
+                        cfg_loc = p->pw_dir;
+                }
+	}
+
+	/* Check if config_loc is terminated by mbus config file name. If    */
+        /* it's not add it.  This is allows environment variable MBUS to     */
+        /* point to config file of directory of config file.                 */
+        cfg_loc_len = strlen(cfg_loc);
+	if (cfg_loc_len < MBUS_FILE_NAME_LEN ||
+	    strcmp(cfg_loc + cfg_loc_len - MBUS_FILE_NAME_LEN, MBUS_FILE_NAME)){
+                /* File location does not include config file name.          */
+                cfg_file = (char*)xmalloc(cfg_loc_len + MBUS_FILE_NAME_LEN + 2);
+                sprintf(cfg_file, "%s/%s", cfg_loc, MBUS_FILE_NAME);	
+	} else {
+                cfg_file = xstrdup(cfg_loc);
+	}
+        
+	m->cfgfd = open(cfg_file, O_RDWR | O_CREAT, 0600);
+	if (m->cfgfd == -1) {
+		perror("Unable to open mbus configuration file");
+		abort();
+	}
+
+	/* We attempt to get a lock on the config file, blocking until  */
+	/* the lock can be obtained. The only time this should block is */
+	/* when another instance of this code has a write lock on the   */
+	/* file, because the contents are being updated.                */
+	l.l_type   = F_WRLCK;
+	l.l_start  = 0;
+	l.l_whence = SEEK_SET;
+	l.l_len    = 0;
+	if (fcntl(m->cfgfd, F_SETLKW, &l) == -1) {
+		perror("Unable to lock mbus configuration file");
+		printf("The most likely reason for this error is that %s\n", cfg_file);
+		printf("is on an NFS filestore, and you have not correctly setup file locking. \n");
+		printf("Ask your system administrator to ensure that rpc.lockd and/or rpc.statd\n");
+		printf("are running. \n");
+		abort();
+	}
+
+	xfree(cfg_file);
+
+	if (fstat(m->cfgfd, &s) != 0) {
+		perror("Unable to stat config file\n");
+		abort();
+	}
+	if (s.st_size == 0) {
+		/* Empty file, create with sensible defaults... */
+		rewrite_config(m);
+	} else {
+		/* Read in the contents of the config file... */
+		buf = (char *) xmalloc(s.st_size+1);
+		memset(buf, '\0', s.st_size+1);
+		if (read(m->cfgfd, buf, s.st_size) != s.st_size) {
+			perror("Unable to read config file\n");
+			abort();
+		}
+		/* Check that the file contains sensible information...   */
+		/* This is rather a pathetic check, but it'll do for now! */
+		if (strncmp(buf, "[MBUS]", 6) != 0) {
+			debug_msg("Mbus config file has incorrect header\n");
+			abort();
+		}
+		xfree(buf);
+	}
+#endif
+	m->cfg_locked = TRUE;
+	if (mbus_get_version(m) < MBUS_CONFIG_VERSION) {
+		rewrite_config(m);
+		debug_msg("Updated Mbus configuration database.\n");
+	}
+	if (mbus_get_version(m) > MBUS_CONFIG_VERSION) {
+		debug_msg("Mbus configuration database has later version number than expected.\n");
+		debug_msg("Continuing, in the hope that the extensions are backwards compatible.\n");
+	}
+}
+
+void mbus_unlock_config_file(struct mbus_config *m)
+{
+#ifdef WIN32
+	LONG status;
+	char buffer[MBUS_BUF_SIZE];
+	
+	status = RegCloseKey(m->cfgKey);
+	if (status != ERROR_SUCCESS) {
+		FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, status, 0, buffer, MBUS_BUF_SIZE, NULL);
+		debug_msg("Unable to close registry: %s\n", buffer);
+		abort();
+	}
+	debug_msg("Closed registry entry...\n");
+#else
+	struct flock	l;
+
+	l.l_type   = F_UNLCK;
+	l.l_start  = 0;
+	l.l_whence = SEEK_SET;
+	l.l_len    = 0;
+	if (fcntl(m->cfgfd, F_SETLKW, &l) == -1) {
+		perror("Unable to unlock mbus configuration file");
+		abort();
+	}
+	close(m->cfgfd);
+	m->cfgfd = -1;
+#endif
+	m->cfg_locked = FALSE;
+}
+
+#ifndef WIN32
+static void mbus_get_key(struct mbus_config *m, struct mbus_key *key, const char *id)
+{
+	struct stat	 s;
+	char		*buf;
+	char		*line;
+	char		*tmp;
+	int		 pos;
+        int              linepos;
+
+	ASSERT(m->cfg_locked);
+
+	if (lseek(m->cfgfd, 0, SEEK_SET) == -1) {
+		perror("Can't seek to start of config file");
+		abort();
+	}
+	if (fstat(m->cfgfd, &s) != 0) {
+		perror("Unable to stat config file\n");
+		abort();
+	}
+	/* Read in the contents of the config file... */
+	buf = (char *) xmalloc(s.st_size+1);
+	memset(buf, '\0', s.st_size+1);
+	if (read(m->cfgfd, buf, s.st_size) != s.st_size) {
+		perror("Unable to read config file\n");
+		abort();
+	}
+	
+	line = (char *) xmalloc(s.st_size+1);
+	sscanf(buf, "%s", line);
+	if (strcmp(line, "[MBUS]") != 0) {
+		debug_msg("Invalid .mbus file\n");
+		abort();
+	}
+	pos = strlen(line) + 1;
+	while (pos < s.st_size) {
+                /* get whole line and filter out spaces */
+                /* this is good enough for getting keys */
+                linepos=0;
+                do {
+                    while((buf[pos+linepos]==' ')||(buf[pos+linepos]=='\n')
+                                                 ||(buf[pos+linepos]=='\t'))
+                        pos++;
+                    sscanf(buf+pos+linepos, "%s", line+linepos);                
+                    linepos = strlen(line);
+                } while((buf[pos+linepos]!='\n') && (s.st_size>(pos+linepos+1)));
+                pos += linepos + 1;
+		if (strncmp(line, id, strlen(id)) == 0) {
+			key->algorithm   = (char *) strdup(strtok(line+strlen(id), ",)"));
+			if (strcmp(key->algorithm, "NOENCR") != 0) {
+				key->key     = (char *) strtok(NULL  , ")");
+                                ASSERT(key->key!=NULL);
+				key->key_len = strlen(key->key);
+				tmp = (char *) xmalloc(key->key_len);
+				key->key_len = base64decode(key->key, key->key_len, tmp, key->key_len);
+				key->key = tmp;
+			} else {
+				key->key     = NULL;
+				key->key_len = 0;
+			}
+			xfree(buf);
+			xfree(line);
+			return;
+		}
+	}
+	debug_msg("Unable to read hashkey from config file\n");
+	xfree(buf);
+	xfree(line);
+}
+#endif
+
+void mbus_get_encrkey(struct mbus_config *m, struct mbus_key *key)
+{
+	/* This MUST be called while the config file is locked! */
+	int		 i, j, k;
+#ifdef WIN32
+	long		 status;
+	DWORD		 type;
+	char		*buffer;
+	int	 	 buflen = MBUS_BUF_SIZE;
+	char		*tmp;
+
+	ASSERT(m->cfg_locked);
+	
+	/* Read the key from the registry... */
+	buffer = (char *) xmalloc(MBUS_BUF_SIZE);
+	status = RegQueryValueEx(m->cfgKey, "ENCRYPTIONKEY", 0, &type, buffer, &buflen);
+	if (status != ERROR_SUCCESS) {
+		FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, status, 0, buffer, MBUS_BUF_SIZE, NULL);
+		debug_msg("Unable to get encrkey: %s\n", buffer);
+		abort();
+	}
+	ASSERT(type == REG_SZ);
+	ASSERT(buflen > 0);
+
+	/* Parse the key... */
+	key->algorithm   = strdup(strtok(buffer+1, ",)"));
+	if (strcmp(key->algorithm, "NOENCR") != 0) {
+		key->key     = (char *) strtok(NULL  , ")");
+		key->key_len = strlen(key->key);
+		tmp = (char *) xmalloc(key->key_len);
+		key->key_len = base64decode(key->key, key->key_len, tmp, key->key_len);
+		key->key = tmp;
+	} else {
+		key->key     = NULL;
+		key->key_len = 0;
+	}
+	xfree(buffer);
+#else
+	mbus_get_key(m, key, "ENCRYPTIONKEY=(");
+#endif
+	if (strcmp(key->algorithm, "DES") == 0) {
+		ASSERT(key->key != NULL);
+		ASSERT(key->key_len == 8);
+
+		/* check parity bits */
+		for (i = 0; i < 8; ++i) 
+		{
+			k = key->key[i] & 0xfe;
+			j = k;
+			j ^= j >> 4;
+			j ^= j >> 2;
+			j ^= j >> 1;
+			j = (j & 1) ^ 1;
+			ASSERT((key->key[i] & 0x01) == j);
+		}
+	}
+}
+
+void mbus_get_hashkey(struct mbus_config *m, struct mbus_key *key)
+{
+	/* This MUST be called while the config file is locked! */
+#ifdef WIN32
+	long	 status;
+	DWORD	 type;
+	char	*buffer;
+	int	 buflen = MBUS_BUF_SIZE;
+	char	*tmp;
+
+	ASSERT(m->cfg_locked);
+	
+	/* Read the key from the registry... */
+	buffer = (char *) xmalloc(MBUS_BUF_SIZE);
+	status = RegQueryValueEx(m->cfgKey, "HASHKEY", 0, &type, buffer, &buflen);
+	if (status != ERROR_SUCCESS) {
+		FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, status, 0, buffer, MBUS_BUF_SIZE, NULL);
+		debug_msg("Unable to get encrkey: %s\n", buffer);
+		abort();
+	}
+	ASSERT(type == REG_SZ);
+	ASSERT(buflen > 0);
+
+	/* Parse the key... */
+	key->algorithm   = strdup(strtok(buffer+1, ","));
+	key->key         = strtok(NULL  , ")");
+	key->key_len     = strlen(key->key);
+
+	/* Decode the key... */
+	tmp = (char *) xmalloc(key->key_len);
+	key->key_len = base64decode(key->key, key->key_len, tmp, key->key_len);
+	key->key = tmp;
+
+	xfree(buffer);
+#else
+	mbus_get_key(m, key, "HASHKEY=(");
+#endif
+}
+
+void mbus_get_net_addr(struct mbus_config *m, char *net_addr, uint16_t *net_port, int *net_scope)
+{
+#ifdef WIN32
+	long	 status;
+	DWORD	 type;
+	char	*buffer;
+	int	 buflen = MBUS_BUF_SIZE;
+	uint32_t port;
+
+	ASSERT(m->cfg_locked);
+	
+	/* Read the key from the registry... */
+	buffer = (char *) xmalloc(MBUS_BUF_SIZE);
+        buflen = MBUS_BUF_SIZE;
+	status = RegQueryValueEx(m->cfgKey, "ADDRESS", 0, &type, buffer, &buflen);
+	if (status != ERROR_SUCCESS) {
+		FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, status, 0, buffer, MBUS_BUF_SIZE, NULL);
+		debug_msg("Unable to get address: %s\n", buffer);
+		strcpy(net_addr, MBUS_DEFAULT_NET_ADDR);
+	} else {
+		ASSERT(type == REG_SZ);
+		ASSERT(buflen > 0);
+		strncpy(net_addr, buffer, buflen);
+	}
+
+	buflen = sizeof(port);
+	status = RegQueryValueEx(m->cfgKey, "PORT", 0, &type, (uint8_t *) &port, &buflen);
+	if (status != ERROR_SUCCESS) {
+		FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, status, 0, buffer, MBUS_BUF_SIZE, NULL);
+		debug_msg("Unable to get port: %s\n", buffer);
+		*net_port  = MBUS_DEFAULT_NET_PORT;
+	} else {
+		ASSERT(type == REG_DWORD);
+		ASSERT(buflen == 4);
+		*net_port = (uint16_t) port;
+	}
+
+	buflen = MBUS_BUF_SIZE;
+	status = RegQueryValueEx(m->cfgKey, "SCOPE", 0, &type, buffer, &buflen);
+	if (status != ERROR_SUCCESS) {
+		FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, status, 0, buffer, MBUS_BUF_SIZE, NULL);
+		debug_msg("Unable to get scope: %s\n", buffer);
+		*net_scope = MBUS_DEFAULT_SCOPE;
+	} else {
+		ASSERT(type == REG_SZ);
+		ASSERT(buflen > 0);
+		if (strncmp(buffer, SCOPE_HOSTLOCAL_NAME, strlen(SCOPE_HOSTLOCAL_NAME)) == 0) {
+			*net_scope = SCOPE_HOSTLOCAL;
+		} else if (strncmp(buffer, SCOPE_LINKLOCAL_NAME, strlen(SCOPE_LINKLOCAL_NAME)) == 0) {
+			*net_scope = SCOPE_LINKLOCAL;
+		} else {
+			debug_msg("Unrecognized scope: %s\n", buffer);
+			*net_scope = MBUS_DEFAULT_SCOPE;
+		}
+	}
+        xfree(buffer);
+#else
+	struct stat	 s;
+	char		*buf;
+	char		*line;
+	int		 pos;
+	int              pos2;
+        int              linepos;
+
+	int              scope;
+	char            *addr;
+	uint16_t        port;
+
+	ASSERT(m->cfg_locked);
+
+	addr = (char *)xmalloc(20);
+	memset(addr, 0, 20);
+	port = 0;
+	scope = -1;
+	
+
+	if (lseek(m->cfgfd, 0, SEEK_SET) == -1) {
+		perror("Can't seek to start of config file");
+		abort();
+	}
+	if (fstat(m->cfgfd, &s) != 0) {
+		perror("Unable to stat config file\n");
+		abort();
+	}
+	/* Read in the contents of the config file... */
+	buf = (char *) xmalloc(s.st_size+1);
+	memset(buf, '\0', s.st_size+1);
+	if (read(m->cfgfd, buf, s.st_size) != s.st_size) {
+		perror("Unable to read config file\n");
+		abort();
+	}
+	
+	line = (char *) xmalloc(s.st_size+1);
+	sscanf(buf, "%s", line);
+	if (strcmp(line, "[MBUS]") != 0) {
+		debug_msg("Invalid .mbus file\n");
+		abort();
+	}
+	pos = strlen(line) + 1;
+	while (pos < s.st_size) {
+                /* get whole line and filter out spaces */
+                linepos=0;
+                do {
+                    while((buf[pos+linepos]==' ')||(buf[pos+linepos]=='\n')
+                                                 ||(buf[pos+linepos]=='\t'))
+                        pos++;
+                    sscanf(buf+pos+linepos, "%s", line+linepos);                
+                    linepos = strlen(line);
+  
+                } while((buf[pos+linepos]!='\n') && (s.st_size>(pos+linepos+1)));
+                pos += linepos + 1;     
+		if (strncmp(line, "SCOPE", strlen("SCOPE")) == 0) {
+		    pos2 = strlen("SCOPE") + 1;
+		    if (strncmp(line+pos2, SCOPE_HOSTLOCAL_NAME, 
+				strlen(SCOPE_HOSTLOCAL_NAME)) == 0) {
+			scope = SCOPE_HOSTLOCAL;
+		    }
+		    if (strncmp(line+pos2, SCOPE_LINKLOCAL_NAME, 
+				strlen(SCOPE_LINKLOCAL_NAME)) == 0) {
+			scope = SCOPE_LINKLOCAL ;
+		    }
+		}
+		if (strncmp(line, "ADDRESS", strlen("ADDRESS")) == 0) {
+		    pos2 = strlen("ADDRESS") + 1;
+		    strncpy(addr, line+pos2, 16);
+		}
+		if (strncmp(line, "PORT", strlen("PORT")) == 0) {
+		    pos2 = strlen("PORT") + 1;
+		    port = atoi(line+pos2);
+		}
+		    
+	}
+	/* If we did not find all values, fill in the default ones */
+	*net_port  = (port>0)?port:MBUS_DEFAULT_NET_PORT;
+	*net_scope = (scope!=-1)?scope:MBUS_DEFAULT_SCOPE;
+	if (strlen(addr)>0) {
+		strncpy(net_addr, addr, 16);
+	} else {
+		strcpy(net_addr, MBUS_DEFAULT_NET_ADDR);
+	}
+	debug_msg("using Addr:%s Port:%d Scope:%s for MBUS\n", 
+		  net_addr, *net_port, (*net_scope==0)?SCOPE_HOSTLOCAL_NAME:SCOPE_LINKLOCAL_NAME);
+	xfree(buf);
+	xfree(line);
+	xfree(addr);
+#endif
+}
+
+int mbus_get_version(struct mbus_config *m)
+{
+#ifdef WIN32
+	long		status;
+	DWORD		type;
+	uint32_t	cver;
+	int		verl;
+	char		buffer[MBUS_BUF_SIZE];
+
+	ASSERT(m->cfg_locked);
+	
+	/* Read the key from the registry... */
+        verl = sizeof(&cver);
+	status = RegQueryValueEx(m->cfgKey, "CONFIG_VERSION", 0, &type, (uint8_t *) &cver, &verl);
+	if (status != ERROR_SUCCESS) {
+		FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, status, 0, buffer, MBUS_BUF_SIZE, NULL);
+		debug_msg("Unable to get version: %s\n", buffer);
+		return 0;
+	}
+	ASSERT(type == REG_DWORD);
+	ASSERT(verl == 4);
+	return cver;
+#else
+	struct stat	 s;
+	char		*buf;
+	char		*line;
+	int		 pos;
+	int              pos2;
+        int              linepos;
+	int		 version = 0;
+
+	ASSERT(m->cfg_locked);
+
+	if (lseek(m->cfgfd, 0, SEEK_SET) == -1) {
+		perror("Can't seek to start of config file");
+		abort();
+	}
+	if (fstat(m->cfgfd, &s) != 0) {
+		perror("Unable to stat config file\n");
+		abort();
+	}
+	/* Read in the contents of the config file... */
+	buf = (char *) xmalloc(s.st_size+1);
+	memset(buf, '\0', s.st_size+1);
+	if (read(m->cfgfd, buf, s.st_size) != s.st_size) {
+		perror("Unable to read config file\n");
+		abort();
+	}
+	
+	line = (char *) xmalloc(s.st_size+1);
+	sscanf(buf, "%s", line);
+	if (strcmp(line, "[MBUS]") != 0) {
+		debug_msg("Invalid .mbus file\n");
+		abort();
+	}
+	pos = strlen(line) + 1;
+	while (pos < s.st_size) {
+                /* get whole line and filter out spaces */
+                linepos=0;
+                do {
+			while((buf[pos+linepos]==' ')||(buf[pos+linepos]=='\n') ||(buf[pos+linepos]=='\t')) {
+				pos++;
+			}
+			sscanf(buf+pos+linepos, "%s", line+linepos);                
+			linepos = strlen(line);
+                } while((buf[pos+linepos]!='\n') && (s.st_size>(pos+linepos+1)));
+                pos += linepos + 1;     
+		if (strncmp(line, "CONFIG_VERSION", strlen("CONFIG_VERSION")) == 0) {
+		    pos2    = strlen("CONFIG_VERSION") + 1;
+		    version = atoi(line+pos2);
+		}
+		    
+	}
+	xfree(buf);
+	xfree(line);
+	return version;
+#endif
+}
+
+struct mbus_config *mbus_create_config(void)
+{
+	return (struct mbus_config *) xmalloc(sizeof(struct mbus_config));
+}
+

Added: experimental/j/Elphel333/rtp/daemon/rtp/mbus_config.h
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/mbus_config.h	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/mbus_config.h	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,77 @@
+/*
+ * FILE:    mbus_config.h
+ * AUTHORS: Colin Perkins
+ * 
+ * Copyright (c) 1999-2000 University College London
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, is permitted provided that the following conditions 
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by the Computer Science
+ *      Department at University College London
+ * 4. Neither the name of the University nor of the Department may be used
+ *    to endorse or promote products derived from this software without
+ *    specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _MBUS_CONFIG
+#define _MBUS_CONFIG
+
+struct mbus_key {
+	char	*algorithm;
+	char	*key;
+	int	 key_len;
+};
+
+struct mbus_config;
+
+#define MBUS_CONFIG_VERSION	 1
+
+#define SCOPE_HOSTLOCAL       	 0
+#define SCOPE_HOSTLOCAL_NAME 	"HOSTLOCAL"
+#define SCOPE_LINKLOCAL       	 1
+#define SCOPE_LINKLOCAL_NAME 	"LINKLOCAL"
+
+#define MBUS_DEFAULT_NET_ADDR 	"224.255.222.239"
+#define MBUS_DEFAULT_NET_PORT 	 47000
+#define MBUS_DEFAULT_SCOPE    	 SCOPE_HOSTLOCAL
+#define MBUS_DEFAULT_SCOPE_NAME	 SCOPE_HOSTLOCAL_NAME
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+char *mbus_new_encrkey(void);
+char *mbus_new_hashkey(void);
+void mbus_lock_config_file(struct mbus_config *m);
+void mbus_unlock_config_file(struct mbus_config *m);
+void mbus_get_encrkey(struct mbus_config *m, struct mbus_key *key);
+void mbus_get_hashkey(struct mbus_config *m, struct mbus_key *key);
+void mbus_get_net_addr(struct mbus_config *m, char *net_addr, uint16_t *net_port, int *net_scope);
+int  mbus_get_version(struct mbus_config *m);
+struct mbus_config *mbus_create_config(void);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif

Added: experimental/j/Elphel333/rtp/daemon/rtp/mbus_parser.c
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/mbus_parser.c	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/mbus_parser.c	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,257 @@
+/*
+ * FILE:     mbus_parser.c
+ * AUTHOR:   Colin Perkins
+ * 
+ * Copyright (c) 1997-2000 University College London
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, is permitted provided that the following conditions 
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by the Computer Science
+ *      Department at University College London
+ * 4. Neither the name of the University nor of the Department may be used
+ *    to endorse or promote products derived from this software without
+ *    specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "config_unix.h"
+#include "config_win32.h"
+#include "debug.h"
+#include "memory.h"
+#include "mbus_parser.h"
+
+#define MBUS_PARSER_MAGIC 0xbadface
+
+struct mbus_parser {
+	char	*buffer;	/* Temporary storage for parsing mbus commands 			*/
+	char	*bufend;	/* End of space allocated for parsing, to check for overflows 	*/
+	uint32_t magic;		/* For debugging...                                             */
+};
+
+struct mbus_parser *mbus_parse_init(char *str)
+{
+	struct mbus_parser	*m;
+
+	m = (struct mbus_parser *) xmalloc(sizeof(struct mbus_parser));
+	m->buffer = str;
+	m->bufend = str + strlen(str);
+	m->magic  = MBUS_PARSER_MAGIC;
+	return m;
+}
+
+void mbus_parse_done(struct mbus_parser *m)
+{
+	ASSERT(m->magic == MBUS_PARSER_MAGIC);
+	xfree(m);
+}
+
+#define CHECK_OVERRUN if (m->buffer > m->bufend) {\
+	debug_msg("parse m->buffer overflow\n");\
+	return FALSE;\
+}
+
+int mbus_parse_lst(struct mbus_parser *m, char **l)
+{
+	int instr = FALSE;
+	int inlst = FALSE;
+
+	ASSERT(m->magic == MBUS_PARSER_MAGIC);
+
+        while (isspace((unsigned char)*m->buffer)) {
+                m->buffer++;
+		CHECK_OVERRUN;
+        }
+	if (*m->buffer != '(') {
+		return FALSE;
+	}
+	m->buffer++;
+	*l = m->buffer;
+	while (*m->buffer != '\0') {
+		if ((*m->buffer == '"') && (*(m->buffer-1) != '\\')) {
+			instr = !instr;
+		}
+		if ((*m->buffer == '(') && (*(m->buffer-1) != '\\') && !instr) {
+			inlst = !inlst;
+		}
+		if ((*m->buffer == ')') && (*(m->buffer-1) != '\\') && !instr) {
+			if (inlst) {
+				inlst = !inlst;
+			} else {
+				*m->buffer = '\0';
+				m->buffer++;
+				CHECK_OVERRUN;
+				return TRUE;
+			}
+		}
+		m->buffer++;
+		CHECK_OVERRUN;
+	}
+	return FALSE;
+}
+
+int mbus_parse_str(struct mbus_parser *m, char **s)
+{
+	ASSERT(m->magic == MBUS_PARSER_MAGIC);
+
+        while (isspace((unsigned char)*m->buffer)) {
+                m->buffer++;
+		CHECK_OVERRUN;
+        }
+	if (*m->buffer != '"') {
+		return FALSE;
+	}
+	*s = m->buffer++;
+	while (*m->buffer != '\0') {
+		if ((*m->buffer == '"') && (*(m->buffer-1) != '\\')) {
+			m->buffer++;
+			*m->buffer = '\0';
+			m->buffer++;
+			return TRUE;
+		}
+		m->buffer++;
+		CHECK_OVERRUN;
+	}
+	return FALSE;
+}
+
+int mbus_parse_sym(struct mbus_parser *m, char **s)
+{
+	ASSERT(m->magic == MBUS_PARSER_MAGIC);
+
+        while (isspace((unsigned char)*m->buffer)) {
+                m->buffer++;
+		CHECK_OVERRUN;
+        }
+	if (!isgraph((unsigned char)*m->buffer)) {
+		return FALSE;
+	}
+	*s = m->buffer++;
+	while (!isspace((unsigned char)*m->buffer) && (*m->buffer != '\0')) {
+		m->buffer++;
+		CHECK_OVERRUN;
+	}
+	*m->buffer = '\0';
+	m->buffer++;
+	CHECK_OVERRUN;
+	return TRUE;
+}
+
+int mbus_parse_int(struct mbus_parser *m, int *i)
+{
+	char	*p;
+
+	ASSERT(m->magic == MBUS_PARSER_MAGIC);
+
+        while (isspace((unsigned char)*m->buffer)) {
+                m->buffer++;
+		CHECK_OVERRUN;
+        }
+
+	*i = strtol(m->buffer, &p, 10);
+	if (((*i == INT_MAX) || (*i == INT_MIN)) && (errno == ERANGE)) {
+		debug_msg("integer out of range\n");
+		return FALSE;
+	}
+
+	if (p == m->buffer) {
+		return FALSE;
+	}
+	if (!isspace((unsigned char)*p) && (*p != '\0')) {
+		return FALSE;
+	}
+	m->buffer = p;
+	CHECK_OVERRUN;
+	return TRUE;
+}
+
+int mbus_parse_flt(struct mbus_parser *m, double *d)
+{
+	char	*p;
+
+	ASSERT(m->magic == MBUS_PARSER_MAGIC);
+
+        while (isspace((unsigned char)*m->buffer)) {
+                m->buffer++;
+		CHECK_OVERRUN;
+        }
+
+	*d = strtod(m->buffer, &p);
+	if (errno == ERANGE) {
+		debug_msg("float out of range\n");
+		return FALSE;
+	}
+
+	if (p == m->buffer) {
+		return FALSE;
+	}
+	if (!isspace((unsigned char)*p) && (*p != '\0')) {
+		return FALSE;
+	}
+	m->buffer = p;
+	CHECK_OVERRUN;
+	return TRUE;
+}
+
+char *mbus_decode_str(char *s)
+{
+	int	l = strlen(s);
+	int	i, j;
+
+	/* Check that this an encoded string... */
+	ASSERT(s[0]   == '\"');
+	ASSERT(s[l-1] == '\"');
+
+	for (i=1,j=0; i < l - 1; i++,j++) {
+		if (s[i] == '\\') {
+			i++;
+		}
+		s[j] = s[i];
+	}
+	s[j] = '\0';
+	return s;
+}
+
+char *mbus_encode_str(const char *s)
+{
+	int 	 i, j;
+	int	 len = strlen(s);
+	char	*buf = (char *) xmalloc((len * 2) + 3);
+
+	for (i = 0, j = 1; i < len; i++,j++) {
+		if (s[i] == ' ') {
+			buf[j] = '\\';
+			buf[j+1] = ' ';
+			j++;
+		} else if (s[i] == '\"') {
+			buf[j] = '\\';
+			buf[j+1] = '\"';
+			j++;
+		} else {
+			buf[j] = s[i];
+		}
+	}
+	buf[0]   = '\"';
+	buf[j]   = '\"';
+	buf[j+1] = '\0';
+	return buf;
+}
+

Added: experimental/j/Elphel333/rtp/daemon/rtp/mbus_parser.h
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/mbus_parser.h	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/mbus_parser.h	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,60 @@
+/*
+ * FILE:     mbus_parser.h
+ * AUTHOR:   Colin Perkins
+ * 
+ * Copyright (c) 2000 University College London
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, is permitted provided that the following conditions 
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by the Computer Science
+ *      Department at University College London
+ * 4. Neither the name of the University nor of the Department may be used
+ *    to endorse or promote products derived from this software without
+ *    specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _MBUS_PARSER_H
+#define _MBUS_PARSER_H
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+struct mbus_parser;
+
+struct mbus_parser 	*mbus_parse_init(char *str);
+void	 		 mbus_parse_done(struct mbus_parser *m);
+int			 mbus_parse_lst(struct mbus_parser *m, char **l);
+int			 mbus_parse_str(struct mbus_parser *m, char **s);
+int			 mbus_parse_sym(struct mbus_parser *m, char **s);
+int			 mbus_parse_int(struct mbus_parser *m, int *i);
+int			 mbus_parse_flt(struct mbus_parser *m, double *d);
+char			*mbus_decode_str(char *s);
+char			*mbus_encode_str(const char *s);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* _MBUS_PARSER_H */
+

Added: experimental/j/Elphel333/rtp/daemon/rtp/md5.c
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/md5.c	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/md5.c	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,319 @@
+/*
+ * MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm
+ */
+
+/*
+ * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All rights
+ * reserved.
+ * 
+ * License to copy and use this software is granted provided that it is
+ * identified as the "RSA Data Security, Inc. MD5 Message-Digest Algorithm"
+ * in all material mentioning or referencing this software or this function.
+ * 
+ * License is also granted to make and use derivative works provided that such
+ * works are identified as "derived from the RSA Data Security, Inc. MD5
+ * Message-Digest Algorithm" in all material mentioning or referencing the
+ * derived work.
+ * 
+ * RSA Data Security, Inc. makes no representations concerning either the
+ * merchantability of this software or the suitability of this software for
+ * any particular purpose. It is provided "as is" without express or implied
+ * warranty of any kind.
+ * 
+ * These notices must be retained in any copies of any part of this
+ * documentation and/or software.
+ */
+
+#include "config_unix.h"
+#include "config_win32.h"
+#include "md5.h"
+
+/*
+ * Constants for MD5Transform routine.
+ */
+#define S11 7
+#define S12 12
+#define S13 17
+#define S14 22
+#define S21 5
+#define S22 9
+#define S23 14
+#define S24 20
+#define S31 4
+#define S32 11
+#define S33 16
+#define S34 23
+#define S41 6
+#define S42 10
+#define S43 15
+#define S44 21
+
+static unsigned char PADDING[64] = {
+	0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+/*
+ * F, G, H and I are basic MD5 functions.
+ */
+#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
+#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
+#define H(x, y, z) ((x) ^ (y) ^ (z))
+#define I(x, y, z) ((y) ^ ((x) | (~z)))
+
+/*
+ * ROTATE_LEFT rotates x left n bits.
+ */
+#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
+
+/*
+ * FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4. Rotation is
+ * separate from addition to prevent recomputation.
+ */
+#define FF(a, b, c, d, x, s, ac) { \
+ (a) += F ((b), (c), (d)) + (x) + (uint32_t)(ac); \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ (a) += (b); \
+  }
+#define GG(a, b, c, d, x, s, ac) { \
+ (a) += G ((b), (c), (d)) + (x) + (uint32_t)(ac); \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ (a) += (b); \
+  }
+#define HH(a, b, c, d, x, s, ac) { \
+ (a) += H ((b), (c), (d)) + (x) + (uint32_t)(ac); \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ (a) += (b); \
+  }
+#define II(a, b, c, d, x, s, ac) { \
+ (a) += I ((b), (c), (d)) + (x) + (uint32_t)(ac); \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ (a) += (b); \
+  }
+
+/*
+ * Encodes input (uint32_t) into output (unsigned char). Assumes len is a
+ * multiple of 4.
+ */
+static void 
+Encode(unsigned char *output, uint32_t * input, unsigned int len)
+{
+	unsigned int    i, j;
+
+	ASSERT((len % 4) == 0);
+
+	for (i = 0, j = 0; j < len; i++, j += 4) {
+		output[j] = (unsigned char) (input[i] & 0xff);
+		output[j + 1] = (unsigned char) ((input[i] >> 8) & 0xff);
+		output[j + 2] = (unsigned char) ((input[i] >> 16) & 0xff);
+		output[j + 3] = (unsigned char) ((input[i] >> 24) & 0xff);
+	}
+}
+
+/*
+ * Decodes input (unsigned char) into output (uint32_t). Assumes len is a
+ * multiple of 4.
+ */
+static void 
+Decode(uint32_t * output, unsigned char *input, unsigned int len)
+{
+	unsigned int    i, j;
+
+	for (i = 0, j = 0; j < len; i++, j += 4)
+		output[i] = ((uint32_t) input[j]) | (((uint32_t) input[j + 1]) << 8) |
+			(((uint32_t) input[j + 2]) << 16) | (((uint32_t) input[j + 3]) << 24);
+}
+
+/*
+ * MD5 basic transformation. Transforms state based on block.
+ */
+static void 
+MD5Transform(uint32_t state[4], unsigned char block[64])
+{
+	uint32_t           a = state[0], b = state[1], c = state[2], d = state[3],
+	                x[16];
+
+	Decode(x, block, 64);
+
+	/* Round 1 */
+	FF(a, b, c, d, x[0], S11, 0xd76aa478);	/* 1 */
+	FF(d, a, b, c, x[1], S12, 0xe8c7b756);	/* 2 */
+	FF(c, d, a, b, x[2], S13, 0x242070db);	/* 3 */
+	FF(b, c, d, a, x[3], S14, 0xc1bdceee);	/* 4 */
+	FF(a, b, c, d, x[4], S11, 0xf57c0faf);	/* 5 */
+	FF(d, a, b, c, x[5], S12, 0x4787c62a);	/* 6 */
+	FF(c, d, a, b, x[6], S13, 0xa8304613);	/* 7 */
+	FF(b, c, d, a, x[7], S14, 0xfd469501);	/* 8 */
+	FF(a, b, c, d, x[8], S11, 0x698098d8);	/* 9 */
+	FF(d, a, b, c, x[9], S12, 0x8b44f7af);	/* 10 */
+	FF(c, d, a, b, x[10], S13, 0xffff5bb1);	/* 11 */
+	FF(b, c, d, a, x[11], S14, 0x895cd7be);	/* 12 */
+	FF(a, b, c, d, x[12], S11, 0x6b901122);	/* 13 */
+	FF(d, a, b, c, x[13], S12, 0xfd987193);	/* 14 */
+	FF(c, d, a, b, x[14], S13, 0xa679438e);	/* 15 */
+	FF(b, c, d, a, x[15], S14, 0x49b40821);	/* 16 */
+
+	/* Round 2 */
+	GG(a, b, c, d, x[1], S21, 0xf61e2562);	/* 17 */
+	GG(d, a, b, c, x[6], S22, 0xc040b340);	/* 18 */
+	GG(c, d, a, b, x[11], S23, 0x265e5a51);	/* 19 */
+	GG(b, c, d, a, x[0], S24, 0xe9b6c7aa);	/* 20 */
+	GG(a, b, c, d, x[5], S21, 0xd62f105d);	/* 21 */
+	GG(d, a, b, c, x[10], S22, 0x2441453);	/* 22 */
+	GG(c, d, a, b, x[15], S23, 0xd8a1e681);	/* 23 */
+	GG(b, c, d, a, x[4], S24, 0xe7d3fbc8);	/* 24 */
+	GG(a, b, c, d, x[9], S21, 0x21e1cde6);	/* 25 */
+	GG(d, a, b, c, x[14], S22, 0xc33707d6);	/* 26 */
+	GG(c, d, a, b, x[3], S23, 0xf4d50d87);	/* 27 */
+	GG(b, c, d, a, x[8], S24, 0x455a14ed);	/* 28 */
+	GG(a, b, c, d, x[13], S21, 0xa9e3e905);	/* 29 */
+	GG(d, a, b, c, x[2], S22, 0xfcefa3f8);	/* 30 */
+	GG(c, d, a, b, x[7], S23, 0x676f02d9);	/* 31 */
+	GG(b, c, d, a, x[12], S24, 0x8d2a4c8a);	/* 32 */
+
+	/* Round 3 */
+	HH(a, b, c, d, x[5], S31, 0xfffa3942);	/* 33 */
+	HH(d, a, b, c, x[8], S32, 0x8771f681);	/* 34 */
+	HH(c, d, a, b, x[11], S33, 0x6d9d6122);	/* 35 */
+	HH(b, c, d, a, x[14], S34, 0xfde5380c);	/* 36 */
+	HH(a, b, c, d, x[1], S31, 0xa4beea44);	/* 37 */
+	HH(d, a, b, c, x[4], S32, 0x4bdecfa9);	/* 38 */
+	HH(c, d, a, b, x[7], S33, 0xf6bb4b60);	/* 39 */
+	HH(b, c, d, a, x[10], S34, 0xbebfbc70);	/* 40 */
+	HH(a, b, c, d, x[13], S31, 0x289b7ec6);	/* 41 */
+	HH(d, a, b, c, x[0], S32, 0xeaa127fa);	/* 42 */
+	HH(c, d, a, b, x[3], S33, 0xd4ef3085);	/* 43 */
+	HH(b, c, d, a, x[6], S34, 0x4881d05);	/* 44 */
+	HH(a, b, c, d, x[9], S31, 0xd9d4d039);	/* 45 */
+	HH(d, a, b, c, x[12], S32, 0xe6db99e5);	/* 46 */
+	HH(c, d, a, b, x[15], S33, 0x1fa27cf8);	/* 47 */
+	HH(b, c, d, a, x[2], S34, 0xc4ac5665);	/* 48 */
+
+	/* Round 4 */
+	II(a, b, c, d, x[0], S41, 0xf4292244);	/* 49 */
+	II(d, a, b, c, x[7], S42, 0x432aff97);	/* 50 */
+	II(c, d, a, b, x[14], S43, 0xab9423a7);	/* 51 */
+	II(b, c, d, a, x[5], S44, 0xfc93a039);	/* 52 */
+	II(a, b, c, d, x[12], S41, 0x655b59c3);	/* 53 */
+	II(d, a, b, c, x[3], S42, 0x8f0ccc92);	/* 54 */
+	II(c, d, a, b, x[10], S43, 0xffeff47d);	/* 55 */
+	II(b, c, d, a, x[1], S44, 0x85845dd1);	/* 56 */
+	II(a, b, c, d, x[8], S41, 0x6fa87e4f);	/* 57 */
+	II(d, a, b, c, x[15], S42, 0xfe2ce6e0);	/* 58 */
+	II(c, d, a, b, x[6], S43, 0xa3014314);	/* 59 */
+	II(b, c, d, a, x[13], S44, 0x4e0811a1);	/* 60 */
+	II(a, b, c, d, x[4], S41, 0xf7537e82);	/* 61 */
+	II(d, a, b, c, x[11], S42, 0xbd3af235);	/* 62 */
+	II(c, d, a, b, x[2], S43, 0x2ad7d2bb);	/* 63 */
+	II(b, c, d, a, x[9], S44, 0xeb86d391);	/* 64 */
+
+	state[0] += a;
+	state[1] += b;
+	state[2] += c;
+	state[3] += d;
+
+	/*
+	 * Zeroize sensitive information.
+	 */
+	memset((unsigned char *) x, 0, sizeof(x));
+}
+
+/**
+ * MD5Init:
+ * @context: MD5 context to be initialized.
+ * 
+ * Initializes MD5 context for the start of message digest computation.
+ **/
+void 
+MD5Init(MD5_CTX * context)
+{
+	context->count[0] = context->count[1] = 0;
+	/* Load magic initialization constants.  */
+	context->state[0] = 0x67452301;
+	context->state[1] = 0xefcdab89;
+	context->state[2] = 0x98badcfe;
+	context->state[3] = 0x10325476;
+}
+
+/**
+ * MD5Update:
+ * @context: MD5 context to be updated.
+ * @input: pointer to data to be fed into MD5 algorithm.
+ * @inputLen: size of @input data in bytes.
+ * 
+ * MD5 block update operation. Continues an MD5 message-digest operation,
+ * processing another message block, and updating the context.
+ **/
+
+void 
+MD5Update(MD5_CTX * context, unsigned char *input, unsigned int inputLen)
+{
+	unsigned int    i, index, partLen;
+
+	/* Compute number of bytes mod 64 */
+	index = (unsigned int) ((context->count[0] >> 3) & 0x3F);
+
+	/* Update number of bits */
+	if ((context->count[0] += ((uint32_t) inputLen << 3)) < ((uint32_t) inputLen << 3)) {
+		context->count[1]++;
+	}
+	context->count[1] += ((uint32_t) inputLen >> 29);
+
+	partLen = 64 - index;
+
+	/* Transform as many times as possible.  */
+	if (inputLen >= partLen) {
+		memcpy((unsigned char *) & context->buffer[index], (unsigned char *) input, partLen);
+		MD5Transform(context->state, context->buffer);
+
+		for (i = partLen; i + 63 < inputLen; i += 64) {
+			MD5Transform(context->state, &input[i]);
+		}
+		index = 0;
+	} else {
+		i = 0;
+	}
+	/* Buffer remaining input */
+	if ((inputLen - i) != 0) {
+		memcpy((unsigned char *) & context->buffer[index], (unsigned char *) & input[i], inputLen - i);
+	}
+}
+
+/**
+ * MD5Final:
+ * @digest: 16-byte buffer to write MD5 checksum.
+ * @context: MD5 context to be finalized.
+ * 
+ * Ends an MD5 message-digest operation, writing the the message
+ * digest and zeroing the context.  The context must be initialized
+ * with MD5Init() before being used for other MD5 checksum calculations.
+ **/
+
+void 
+MD5Final(unsigned char digest[16], MD5_CTX * context)
+{
+	unsigned char   bits[8];
+	unsigned int    index, padLen;
+
+	/* Save number of bits */
+	Encode(bits, context->count, 8);
+
+	/*
+	 * Pad out to 56 mod 64.
+	 */
+	index = (unsigned int) ((context->count[0] >> 3) & 0x3f);
+	padLen = (index < 56) ? (56 - index) : (120 - index);
+	MD5Update(context, PADDING, padLen);
+
+	/* Append length (before padding) */
+	MD5Update(context, bits, 8);
+	/* Store state in digest */
+	Encode(digest, context->state, 16);
+
+	/*
+	 * Zeroize sensitive information.
+	 */
+	memset((unsigned char *) context, 0, sizeof(*context));
+}
+

Added: experimental/j/Elphel333/rtp/daemon/rtp/md5.h
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/md5.h	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/md5.h	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,43 @@
+/* MD5.H - header file for MD5C.C
+ */
+
+/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
+rights reserved.
+
+License to copy and use this software is granted provided that it
+is identified as the "RSA Data Security, Inc. MD5 Message-Digest
+Algorithm" in all material mentioning or referencing this software
+or this function.
+
+License is also granted to make and use derivative works provided
+that such works are identified as "derived from the RSA Data
+Security, Inc. MD5 Message-Digest Algorithm" in all material
+mentioning or referencing the derived work.
+
+RSA Data Security, Inc. makes no representations concerning either
+the merchantability of this software or the suitability of this
+software for any particular purpose. It is provided "as is"
+without express or implied warranty of any kind.
+
+These notices must be retained in any copies of any part of this
+documentation and/or software.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* MD5 context. */
+typedef struct {
+  uint32_t state[4];            /* state (ABCD) */
+  uint32_t count[2];        	/* number of bits, modulo 2^64 (lsb first) */
+  unsigned char buffer[64];     /* input buffer */
+} MD5_CTX;
+
+void MD5Init(MD5_CTX *context);
+void MD5Update(MD5_CTX *context, unsigned char *input, unsigned int inputLen);
+void MD5Final(unsigned char digest[16], MD5_CTX *context);
+
+#ifdef __cplusplus
+}
+#endif

Added: experimental/j/Elphel333/rtp/daemon/rtp/memory.c
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/memory.c	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/memory.c	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,585 @@
+/*
+ * FILE:    memory.c
+ * AUTHORS:  Isidor Kouvelas / Colin Perkins / Mark Handley / Orion Hodson
+ *
+ * $Revision: 1.1.1.1 $
+ * $Date: 2005/03/18 09:19:06 $
+ *
+ * Copyright (c) 1995-2000 University College London
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, is permitted provided that the following conditions 
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by the Computer Science
+ *      Department at University College London
+ * 4. Neither the name of the University nor of the Department may be used
+ *    to endorse or promote products derived from this software without
+ *    specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "config_unix.h"
+#include "config_win32.h"
+#include "debug.h"
+#include "memory.h"
+#include "util.h"
+
+#ifdef DEBUG_MEM
+
+/* Custom memory routines are here, down to #else, defaults follow */
+
+#define MAX_ADDRS         65536
+#define MAGIC_MEMORY      0xdeadbeef
+#define MAGIC_MEMORY_SIZE 4
+
+/* Allocated block format is:
+ * <chk_header> <memory chunk...> <trailing magic number>
+ */
+
+typedef struct {
+        uint32_t key;   /* Original allocation number   */
+        uint32_t size;  /* Size of allocation requested */
+        uint32_t pad;   /* Alignment padding to 8 bytes */
+        uint32_t magic; /* Magic number                 */
+} chk_header;
+
+typedef struct s_alloc_blk {
+        uint32_t    key;     /* Key in table (ascending) */
+        chk_header *addr;
+        char       *filen;   /* file where allocated     */
+        int         line;    /* line where allocated     */
+        size_t      length;  /* size of allocation       */
+        int         blen;    /* size passed to block_alloc (if relevent) */
+        int         est;     /* time last touched in order of all allocation and reclaims */
+} alloc_blk;
+
+/* Table is ordered by key */
+static alloc_blk mem_item[MAX_ADDRS];
+
+static int   naddr = 0; /* number of allocations */
+static int   tick  = 1; /* xmemchk assumes this is one, do not change without checking why */
+
+static int   init  = 0;
+
+/**
+ * xdoneinit:
+ * @void: 
+ * 
+ * Marks end of an applications initialization period.  For media
+ * applications with real-time data transfer it's sometimes helpful to
+ * distinguish between memory allocated during application
+ * initialization and when application is running.
+ **/
+
+void xdoneinit(void) 
+{
+	init = tick++;
+}
+
+extern int chk_header_okay(const chk_header *ch);
+int chk_header_okay(const chk_header *ch)
+{
+        const uint8_t *tm; /* tail magic */
+        ASSERT(ch != NULL);
+
+        if (ch->key == MAGIC_MEMORY) {
+                fprintf(stderr, "ERROR: freed unit being checked\n");
+                abort();
+        }
+
+        tm = (const uint8_t*)ch;
+        tm += sizeof(chk_header) + ch->size;
+
+        if (ch->magic != MAGIC_MEMORY) {
+                fprintf(stderr, "ERROR: memory underrun\n");
+                abort();
+                return FALSE;
+        } else if (memcmp(tm, &ch->magic, MAGIC_MEMORY_SIZE)) {
+                fprintf(stderr, "ERROR: memory overrun\n");
+                abort();
+                return FALSE;
+        }
+
+        return TRUE;
+}
+
+static int mem_key_cmp(const void *a, const void *b) {
+        const alloc_blk *g, *h;
+        g = (const alloc_blk*)a;
+        h = (const alloc_blk*)b;
+        if (g->key < h->key) {
+                return -1;
+        } else if (g->key > h->key) {
+                return +1;
+        }
+        return 0;
+}
+
+static alloc_blk *mem_item_find(uint32_t key) {
+        void      *p;
+        alloc_blk  t;
+        t.key = key;
+        p = bsearch((const void*)&t, mem_item, naddr, sizeof(alloc_blk), mem_key_cmp);
+        return (alloc_blk*)p;
+}
+
+/**
+ * xmemchk:
+ * @void: 
+ * 
+ * Check for bounds overruns in all memory allocated with xmalloc(),
+ * xrealloc(), and xstrdup().  Information on corrupted blocks is
+ * rendered on the standard error stream.  This includes where the
+ * block was allocated, the size of the block, and the number of
+ * allocations made since the block was created.
+ **/
+void xmemchk(void)
+{
+        uint32_t    last_key;
+        chk_header *ch;
+        int         i;
+
+	if (naddr > MAX_ADDRS) {
+		fprintf(stderr, "ERROR: Too many addresses for xmemchk()!\n");
+		abort();
+	}
+
+        last_key = 0;
+	for (i = 0; i < naddr; i++) {
+                /* Check for table corruption */
+                if (mem_item[i].key  < last_key) {
+                        fprintf(stderr, "Memory table keys out of order - fatal error");
+                        abort();
+                }
+                last_key = mem_item[i].key;
+                if (mem_item[i].addr == NULL) {
+                        fprintf(stderr, "Memory table entry reference null block - fatal error");
+                        abort();
+                }
+                if (mem_item[i].filen == NULL) {
+                        fprintf(stderr, "Memory table filename missing - fatal error");
+                        abort();
+                }
+                if ((size_t) strlen(mem_item[i].filen) != mem_item[i].length) {
+                        fprintf(stderr, "Memory table filename length corrupted - fatal error");
+                        abort();
+                }
+                
+                /* Check memory */
+                ch = mem_item[i].addr;
+                if (chk_header_okay(ch) == FALSE) {
+                        /* Chk header display which side has gone awry */
+			fprintf(stderr, "Memory check failed!\n");
+			fprintf(stderr, "addr: %p", mem_item[i].addr);
+                        fprintf(stderr, "  size: %6d", ch->size);
+                        fprintf(stderr, "  age: %6d", tick - mem_item[i].est);
+                        fprintf(stderr, "  file: %s", mem_item[i].filen);
+                        fprintf(stderr, "  line: %d", mem_item[i].line);
+                        fprintf(stderr, "\n");
+                        abort();
+                }
+        }
+}
+
+static int 
+alloc_blk_cmp_origin(const void *vab1, const void *vab2)
+{
+        const alloc_blk *ab1, *ab2;
+        int sc;
+        
+        ab1 = (const alloc_blk*)vab1;
+        ab2 = (const alloc_blk*)vab2;
+
+        if (ab1->filen == NULL || ab2->filen == NULL) {
+                if (ab1->filen == NULL && ab2->filen == NULL) {
+                        return 0;
+                } else if (ab1->filen == NULL) {
+                        return +1;
+                } else /* (ab2->filen == NULL)*/ {
+                        return -1;
+                }
+        }
+
+        sc = strcmp(ab1->filen, ab2->filen);
+        if (sc == 0) {
+                if (ab1->line > ab2->line) {
+                        return +1;
+                } else if (ab1->line == ab2->line) {
+                        return 0;
+                } else /* (ab1->line < ab2->line) */{
+                        return -1;
+                }
+        }
+
+        return sc;
+}
+
+static int
+alloc_blk_cmp_est(const void *vab1, const void *vab2)
+{
+        const alloc_blk *ab1, *ab2;
+
+        ab1 = (const alloc_blk*)vab1;        
+        ab2 = (const alloc_blk*)vab2;
+        
+        if (ab1->est > ab2->est) {
+                return +1;
+        } else if (ab1->est == ab2->est) {
+                return 0;
+        } else {
+                return -1;
+        }
+}
+
+/**
+ * xmemdmp:
+ * @void: 
+ * 
+ * Dumps the address, size, age, and point of allocation in code.
+ *
+ **/
+void 
+xmemdmp(void)
+{
+	int i;
+        block_release_all();
+	if (naddr > MAX_ADDRS) {
+		printf("ERROR: Too many addresses for xmemdmp()!\n");
+		abort();
+	}
+
+        qsort(mem_item, naddr, sizeof(mem_item[0]), alloc_blk_cmp_est);
+
+        for (i=0; i<naddr; i++) {
+                printf("%5d",i);                               fflush(stdout);
+                printf("  addr: %p", mem_item[i].addr);        fflush(stdout);
+                printf("  size: %5d", mem_item[i].addr->size); fflush(stdout);
+                printf("  age: %6d", tick - mem_item[i].est);  fflush(stdout);
+                printf("  file: %s", mem_item[i].filen);       fflush(stdout);
+                printf(":%d", mem_item[i].line);               fflush(stdout);
+                if (mem_item[i].blen != 0) { 
+                        printf("  \tblen %d", mem_item[i].blen);   
+                        fflush(stdout);
+                }
+                printf("\n");
+        }
+	printf("Program initialisation finished at age %6d\n", tick-init);
+        qsort(mem_item, naddr, sizeof(mem_item[0]), mem_key_cmp);
+}
+
+
+/* Because block_alloc recycles blocks we need to know which code
+ * fragment takes over responsibility for the memory.  */
+
+/**
+ * xclaim:
+ * @addr: address
+ * @filen: new filename
+ * @line: new allocation line
+ * 
+ * Coerces information in allocation table about allocation file and
+ * line to be @filen and @line.  This is used by the evil
+ * block_alloc() and should probably not be used anywhere else ever.
+ **/
+void 
+xclaim(void *addr, const char *filen, int line)
+{
+        alloc_blk *m;
+        chk_header *ch;
+        
+        ch = ((chk_header *)addr) - 1;
+        m  = mem_item_find(ch->key); 
+
+        if (chk_header_okay(ch) == FALSE) {
+                fprintf(stderr, "xclaim: memory corrupted\n");
+                abort();
+        }
+
+        if (m == NULL) {
+                fprintf(stderr, "xclaim: block not found\n");
+                abort();
+        }
+
+        free(m->filen);
+        m->filen  = strdup(filen);
+        m->length = strlen(filen);
+        m->line   = line;
+        m->est    = tick++;
+}
+
+/**
+ * xmemdist:
+ * @fp: file pointer
+ * 
+ * Dumps information on existing memory allocations to file.
+ **/
+void 
+xmemdist(FILE *fp)
+{
+        int i, last_line=-1, cnt=0, entry=0;
+        char *last_filen = NULL;
+
+        /* This is painful...I don't actually envisage running beyond this dump :-)
+         * 2 sorts are needed, one into order by file, and then back to key order.
+         */
+        qsort(mem_item, naddr, sizeof(mem_item[0]), alloc_blk_cmp_origin);
+        fprintf(fp, "# Distribution of memory allocated\n# <idx> <file> <line> <allocations>\n");
+        for(i = 0; i < naddr; i++) {
+                if (last_filen == NULL ||
+                    last_line  != mem_item[i].line ||
+                    strcmp(last_filen, mem_item[i].filen)) {
+                        if (last_filen != NULL) {
+                                fprintf(fp, "% 3d\n", cnt);
+                        }
+                        cnt = 0;
+                        last_filen = mem_item[i].filen;
+                        last_line  = mem_item[i].line;
+                        fprintf(fp, "% 3d %20s % 4d ", entry, last_filen, last_line);
+                        entry++;
+                }
+                cnt++;
+        }
+        fprintf(fp, "% 3d\n", cnt);
+        /* Restore order */
+        qsort(mem_item, naddr, sizeof(mem_item[0]), mem_key_cmp);
+}
+
+/**
+ * xfree:
+ * @p: pointer to block to freed.
+ * 
+ * Free block of memory.  Semantically equivalent to free(), but
+ * checks for bounds overruns in @p and tidies up state associated
+ * additional functionality.
+ *
+ * Must be used to free memory allocated with xmalloc(), xrealloc(),
+ * and xstrdup().
+ **/
+void 
+xfree(void *p)
+{
+        alloc_blk  *m;
+        chk_header *ch;
+        uint32_t size, delta, magic, idx;
+        
+	if (p == NULL) {
+		printf("ERROR: Attempt to free NULL pointer!\n");
+		abort();
+	}
+        ch = ((chk_header*)p) - 1;
+
+        printf("free at %p\n", ch);
+        /* Validate entry  */
+        if (chk_header_okay(ch) == FALSE) {
+                printf("ERROR: Freeing corrupted block\n");
+                abort();
+        }
+
+        /* Locate in table */
+        m = mem_item_find(ch->key);
+        if (m == NULL) {
+                printf("ERROR: Freeing unallocated or already free'd block\n");
+                abort();
+        }
+
+        /* Trash memory of allocated block, maybe noticed by apps when    
+         * deref'ing free'd */
+        size  = ch->size + sizeof(chk_header) + MAGIC_MEMORY_SIZE;
+        magic = MAGIC_MEMORY;
+        p     = (uint8_t*)ch;
+        while (size > 0) {
+                delta = min(size, 4);
+                memcpy(p, &magic, delta);
+                (uint8_t*)p += delta;
+                size        -= delta;
+        }
+
+        /* Free memory     */
+        free(ch);
+        free(m->filen);
+
+        /* Remove from table */
+        idx = m - mem_item;
+        if (naddr - idx > 0) {
+                memmove(&mem_item[idx], 
+                        &mem_item[idx + 1], 
+                        (naddr - idx - 1) * sizeof(alloc_blk));
+        }
+        naddr--;
+        xmemchk();
+}
+
+void *
+_xmalloc(unsigned size, const char *filen, int line)
+{
+        uint32_t   *data;
+        void       *p;
+        chk_header *ch;
+
+        p = (void*) malloc (size + sizeof(chk_header) + MAGIC_MEMORY_SIZE);
+
+	ASSERT(p     != NULL);
+	ASSERT(filen != NULL);
+
+        /* Fix block header */
+        ch = (chk_header*)p;
+        ch->key   = tick++;
+        ch->size  = size;
+        ch->magic = MAGIC_MEMORY;
+
+	data = (uint32_t*)((chk_header *)p + 1);
+#if 0
+	memset((void*)data, 0xf0, size);
+#else
+	memset((void*)data, 0, size);
+#endif
+        
+        /* Fix block tail */
+        memcpy(((uint8_t*)data) + size, &ch->magic, MAGIC_MEMORY_SIZE);
+
+        /* Check set up okay */
+        if (chk_header_okay(ch) == FALSE) {
+                fprintf(stderr, "Implementation Error\n");
+                abort();
+        }
+
+        /* Add table entry */
+        mem_item[naddr].key    = ch->key;
+	mem_item[naddr].addr   = p;
+	mem_item[naddr].filen  = (char *)strdup(filen);
+	mem_item[naddr].line   = line;
+	mem_item[naddr].length = strlen(filen);
+        mem_item[naddr].blen   = 0;        /* block_alloc'ed len when appropriate     */
+        mem_item[naddr].est    = ch->key;  /* changes when block_alloc recycles block */
+        naddr ++;
+
+	if (naddr >= MAX_ADDRS) {
+		fprintf(stderr, "ERROR: Allocated too much! Table overflow in xmalloc()\n");
+		fprintf(stderr, "       Do you really need to allocate more than %d items?\n", MAX_ADDRS);
+		abort();
+	}
+        
+        if (chk_header_okay(ch) == FALSE) {
+                fprintf(stderr, "Implementation Error\n");
+                abort();
+        }
+
+        printf("malloc at %p\n", p);
+        return (uint8_t*)p + sizeof(chk_header);
+}
+
+void *
+_xrealloc(void *p, unsigned size, const char *filen, int line)
+{
+        alloc_blk  *m;
+        chk_header *ch;
+        uint8_t    *t;
+       
+        ASSERT(p     != NULL);
+        ASSERT(filen != NULL);
+	
+        ch = ((chk_header*) p) - 1;
+        m  = mem_item_find(ch->key);
+        if (m != NULL) {
+                /* Attempt reallocation */
+                m->addr = realloc((void*)ch, size + sizeof(chk_header) + MAGIC_MEMORY_SIZE);
+                if (m->addr == NULL) {
+                        debug_msg("realloc failed\n");
+                        return NULL;
+                }
+                /* Update table */
+                free(m->filen);
+                m->filen  = (char *) strdup(filen);
+                m->line   = line;
+                m->length = strlen(filen);
+                m->est    = tick++;
+                /* Fix chunk header */
+                ch->size  = size;
+                /* Fix trailer */
+                t = (uint8_t*)p + size;
+                memcpy(t, &ch->magic, MAGIC_MEMORY_SIZE);
+                /* Check block is okay */
+                if (chk_header_okay(ch) == FALSE) {
+                        fprintf(stderr, "Implementation Error\n");
+                        abort();
+                }
+                return p;
+	}
+	debug_msg("Trying to xrealloc() memory not which is not allocated\n");
+	abort();
+        return 0;
+}
+
+char *_xstrdup(const char *s1, const char *filen, int line)
+{
+	char 	*s2;
+  
+	s2 = (char *) _xmalloc(strlen(s1)+1, filen, line);
+	if (s2 != NULL) {
+		strcpy(s2, s1);
+        }
+	return (s2);
+}
+#else
+
+void xdoneinit (void) { return; }
+void xmemchk   (void) { return; }
+void xmemdmp   (void) { return; }
+
+void xclaim    (void *p, const char *filen, int line)
+{
+        UNUSED(p);
+        UNUSED(filen);
+        UNUSED(line);
+        return;
+}
+
+void xmemdist (FILE *f) { UNUSED(f); }
+
+void xfree    (void *x) { free(x); }
+
+void *_xmalloc(unsigned int size, const char *filen, int line) {
+	void	*m;
+
+	m = malloc(size);
+
+#ifdef DEBUG
+	/* This is just to check initialization errors in allocated structs */
+	memset(m, 0xf0, size);
+#endif
+	UNUSED(filen);
+	UNUSED(line);
+
+	return m;
+}
+
+void *_xrealloc(void *p, unsigned int size,const char *filen,int line) {
+        UNUSED(filen);
+        UNUSED(line);
+        return realloc(p, size);
+}
+char *_xstrdup(const char *s1, const char *filen, int line) {
+        UNUSED(filen);
+        UNUSED(line);
+        return strdup(s1);
+}
+
+#endif /* DEBUG_MEM */

Added: experimental/j/Elphel333/rtp/daemon/rtp/memory.h
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/memory.h	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/memory.h	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,70 @@
+/*
+ * FILE:    memory.h
+ * PROGRAM: RAT
+ * AUTHOR:  Isidor Kouvelas + Colin Perkins + Orion Hodson
+ *
+ * $Revision: 1.1.1.1 $
+ * $Date: 2005/03/18 09:19:06 $
+ *
+ * Copyright (c) 1995-2000 University College London
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, is permitted provided that the following conditions 
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by the Computer Science
+ *      Department at University College London
+ * 4. Neither the name of the University nor of the Department may be used
+ *    to endorse or promote products derived from this software without
+ *    specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _RAT_MEMORY_H
+#define _RAT_MEMORY_H
+
+#define xmalloc(x)	_xmalloc(x,__FILE__,__LINE__)
+#define xrealloc(p,x)	_xrealloc(p, x,__FILE__,__LINE__)
+#define xstrdup(str)	_xstrdup(str,__FILE__,__LINE__)
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/* Debug Functions */
+void 	 xdoneinit(void);
+void	 xmemchk(void);
+void     xmemdmp(void);
+void     xclaim(void *addr, const char *filen, int line);
+void     xmemdist(FILE *fp);
+
+/* Replacements for regular memory fn's */
+void	 xfree(void *p);
+void	*_xmalloc(unsigned size,const char *filen,int line);
+void	*_xrealloc(void *p,unsigned size,const char *filen,int line);
+char	*_xstrdup(const char *s1, const char *filen, int line);
+void	*_block_alloc(unsigned size, const char *filen, int line);
+void	 _block_free(void *p, int size, int line);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif 

Added: experimental/j/Elphel333/rtp/daemon/rtp/missing
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/missing	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/missing	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,336 @@
+#! /bin/sh
+# Common stub for a few missing GNU programs while installing.
+# Copyright (C) 1996, 1997, 1999, 2000, 2002 Free Software Foundation, Inc.
+# Originally by Fran,cois Pinard <pinard at iro.umontreal.ca>, 1996.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+if test $# -eq 0; then
+  echo 1>&2 "Try \`$0 --help' for more information"
+  exit 1
+fi
+
+run=:
+
+# In the cases where this matters, `missing' is being run in the
+# srcdir already.
+if test -f configure.ac; then
+  configure_ac=configure.ac
+else
+  configure_ac=configure.in
+fi
+
+case "$1" in
+--run)
+  # Try to run requested program, and just exit if it succeeds.
+  run=
+  shift
+  "$@" && exit 0
+  ;;
+esac
+
+# If it does not exist, or fails to run (possibly an outdated version),
+# try to emulate it.
+case "$1" in
+
+  -h|--h|--he|--hel|--help)
+    echo "\
+$0 [OPTION]... PROGRAM [ARGUMENT]...
+
+Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
+error status if there is no known handling for PROGRAM.
+
+Options:
+  -h, --help      display this help and exit
+  -v, --version   output version information and exit
+  --run           try to run the given command, and emulate it if it fails
+
+Supported PROGRAM values:
+  aclocal      touch file \`aclocal.m4'
+  autoconf     touch file \`configure'
+  autoheader   touch file \`config.h.in'
+  automake     touch all \`Makefile.in' files
+  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
+  flex         create \`lex.yy.c', if possible, from existing .c
+  help2man     touch the output file
+  lex          create \`lex.yy.c', if possible, from existing .c
+  makeinfo     touch the output file
+  tar          try tar, gnutar, gtar, then tar without non-portable flags
+  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]"
+    ;;
+
+  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
+    echo "missing 0.4 - GNU automake"
+    ;;
+
+  -*)
+    echo 1>&2 "$0: Unknown \`$1' option"
+    echo 1>&2 "Try \`$0 --help' for more information"
+    exit 1
+    ;;
+
+  aclocal*)
+    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+       # We have it, but it failed.
+       exit 1
+    fi
+
+    echo 1>&2 "\
+WARNING: \`$1' is missing on your system.  You should only need it if
+         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
+         to install the \`Automake' and \`Perl' packages.  Grab them from
+         any GNU archive site."
+    touch aclocal.m4
+    ;;
+
+  autoconf)
+    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+       # We have it, but it failed.
+       exit 1
+    fi
+
+    echo 1>&2 "\
+WARNING: \`$1' is missing on your system.  You should only need it if
+         you modified \`${configure_ac}'.  You might want to install the
+         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
+         archive site."
+    touch configure
+    ;;
+
+  autoheader)
+    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+       # We have it, but it failed.
+       exit 1
+    fi
+
+    echo 1>&2 "\
+WARNING: \`$1' is missing on your system.  You should only need it if
+         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
+         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
+         from any GNU archive site."
+    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
+    test -z "$files" && files="config.h"
+    touch_files=
+    for f in $files; do
+      case "$f" in
+      *:*) touch_files="$touch_files "`echo "$f" |
+				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
+      *) touch_files="$touch_files $f.in";;
+      esac
+    done
+    touch $touch_files
+    ;;
+
+  automake*)
+    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+       # We have it, but it failed.
+       exit 1
+    fi
+
+    echo 1>&2 "\
+WARNING: \`$1' is missing on your system.  You should only need it if
+         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
+         You might want to install the \`Automake' and \`Perl' packages.
+         Grab them from any GNU archive site."
+    find . -type f -name Makefile.am -print |
+	   sed 's/\.am$/.in/' |
+	   while read f; do touch "$f"; done
+    ;;
+
+  autom4te)
+    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+       # We have it, but it failed.
+       exit 1
+    fi
+
+    echo 1>&2 "\
+WARNING: \`$1' is needed, and you do not seem to have it handy on your
+         system.  You might have modified some files without having the
+         proper tools for further handling them.
+         You can get \`$1Help2man' as part of \`Autoconf' from any GNU
+         archive site."
+
+    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
+    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
+    if test -f "$file"; then
+	touch $file
+    else
+	test -z "$file" || exec >$file
+	echo "#! /bin/sh"
+	echo "# Created by GNU Automake missing as a replacement of"
+	echo "#  $ $@"
+	echo "exit 0"
+	chmod +x $file
+	exit 1
+    fi
+    ;;
+
+  bison|yacc)
+    echo 1>&2 "\
+WARNING: \`$1' is missing on your system.  You should only need it if
+         you modified a \`.y' file.  You may need the \`Bison' package
+         in order for those modifications to take effect.  You can get
+         \`Bison' from any GNU archive site."
+    rm -f y.tab.c y.tab.h
+    if [ $# -ne 1 ]; then
+        eval LASTARG="\${$#}"
+	case "$LASTARG" in
+	*.y)
+	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
+	    if [ -f "$SRCFILE" ]; then
+	         cp "$SRCFILE" y.tab.c
+	    fi
+	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
+	    if [ -f "$SRCFILE" ]; then
+	         cp "$SRCFILE" y.tab.h
+	    fi
+	  ;;
+	esac
+    fi
+    if [ ! -f y.tab.h ]; then
+	echo >y.tab.h
+    fi
+    if [ ! -f y.tab.c ]; then
+	echo 'main() { return 0; }' >y.tab.c
+    fi
+    ;;
+
+  lex|flex)
+    echo 1>&2 "\
+WARNING: \`$1' is missing on your system.  You should only need it if
+         you modified a \`.l' file.  You may need the \`Flex' package
+         in order for those modifications to take effect.  You can get
+         \`Flex' from any GNU archive site."
+    rm -f lex.yy.c
+    if [ $# -ne 1 ]; then
+        eval LASTARG="\${$#}"
+	case "$LASTARG" in
+	*.l)
+	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
+	    if [ -f "$SRCFILE" ]; then
+	         cp "$SRCFILE" lex.yy.c
+	    fi
+	  ;;
+	esac
+    fi
+    if [ ! -f lex.yy.c ]; then
+	echo 'main() { return 0; }' >lex.yy.c
+    fi
+    ;;
+
+  help2man)
+    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+       # We have it, but it failed.
+       exit 1
+    fi
+
+    echo 1>&2 "\
+WARNING: \`$1' is missing on your system.  You should only need it if
+	 you modified a dependency of a manual page.  You may need the
+	 \`Help2man' package in order for those modifications to take
+	 effect.  You can get \`Help2man' from any GNU archive site."
+
+    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
+    if test -z "$file"; then
+	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
+    fi
+    if [ -f "$file" ]; then
+	touch $file
+    else
+	test -z "$file" || exec >$file
+	echo ".ab help2man is required to generate this page"
+	exit 1
+    fi
+    ;;
+
+  makeinfo)
+    if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then
+       # We have makeinfo, but it failed.
+       exit 1
+    fi
+
+    echo 1>&2 "\
+WARNING: \`$1' is missing on your system.  You should only need it if
+         you modified a \`.texi' or \`.texinfo' file, or any other file
+         indirectly affecting the aspect of the manual.  The spurious
+         call might also be the consequence of using a buggy \`make' (AIX,
+         DU, IRIX).  You might want to install the \`Texinfo' package or
+         the \`GNU make' package.  Grab either from any GNU archive site."
+    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
+    if test -z "$file"; then
+      file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
+      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
+    fi
+    touch $file
+    ;;
+
+  tar)
+    shift
+    if test -n "$run"; then
+      echo 1>&2 "ERROR: \`tar' requires --run"
+      exit 1
+    fi
+
+    # We have already tried tar in the generic part.
+    # Look for gnutar/gtar before invocation to avoid ugly error
+    # messages.
+    if (gnutar --version > /dev/null 2>&1); then
+       gnutar "$@" && exit 0
+    fi
+    if (gtar --version > /dev/null 2>&1); then
+       gtar "$@" && exit 0
+    fi
+    firstarg="$1"
+    if shift; then
+	case "$firstarg" in
+	*o*)
+	    firstarg=`echo "$firstarg" | sed s/o//`
+	    tar "$firstarg" "$@" && exit 0
+	    ;;
+	esac
+	case "$firstarg" in
+	*h*)
+	    firstarg=`echo "$firstarg" | sed s/h//`
+	    tar "$firstarg" "$@" && exit 0
+	    ;;
+	esac
+    fi
+
+    echo 1>&2 "\
+WARNING: I can't seem to be able to run \`tar' with the given arguments.
+         You may want to install GNU tar or Free paxutils, or check the
+         command line arguments."
+    exit 1
+    ;;
+
+  *)
+    echo 1>&2 "\
+WARNING: \`$1' is needed, and you do not seem to have it handy on your
+         system.  You might have modified some files without having the
+         proper tools for further handling them.  Check the \`README' file,
+         it often tells you about the needed prerequirements for installing
+         this package.  You may also peek at any GNU archive site, in case
+         some other package would contain this missing \`$1' program."
+    exit 1
+    ;;
+esac
+
+exit 0


Property changes on: experimental/j/Elphel333/rtp/daemon/rtp/missing
___________________________________________________________________
Name: svn:executable
   + 

Added: experimental/j/Elphel333/rtp/daemon/rtp/mkinstalldirs
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/mkinstalldirs	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/mkinstalldirs	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,99 @@
+#! /bin/sh
+# mkinstalldirs --- make directory hierarchy
+# Author: Noah Friedman <friedman at prep.ai.mit.edu>
+# Created: 1993-05-16
+# Public domain
+
+errstatus=0
+dirmode=""
+
+usage="\
+Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..."
+
+# process command line arguments
+while test $# -gt 0 ; do
+   case "${1}" in
+     -h | --help | --h* )			# -h for help
+	echo "${usage}" 1>&2; exit 0 ;;
+     -m )					# -m PERM arg
+	shift
+	test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; }
+	dirmode="${1}"
+	shift ;;
+     -- ) shift; break ;;			# stop option processing
+     -* ) echo "${usage}" 1>&2; exit 1 ;;	# unknown option
+     * )  break ;;				# first non-opt arg
+   esac
+done
+
+for file
+do
+  if test -d "$file"; then
+    shift
+  else
+    break
+  fi
+done
+
+case $# in
+0) exit 0 ;;
+esac
+
+case $dirmode in
+'')
+  if mkdir -p -- . 2>/dev/null; then
+    echo "mkdir -p -- $*"
+    exec mkdir -p -- "$@"
+  fi ;;
+*)
+  if mkdir -m "$dirmode" -p -- . 2>/dev/null; then
+    echo "mkdir -m $dirmode -p -- $*"
+    exec mkdir -m "$dirmode" -p -- "$@"
+  fi ;;
+esac
+
+for file
+do
+   set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
+   shift
+
+   pathcomp=
+   for d
+   do
+     pathcomp="$pathcomp$d"
+     case "$pathcomp" in
+       -* ) pathcomp=./$pathcomp ;;
+     esac
+
+     if test ! -d "$pathcomp"; then
+	echo "mkdir $pathcomp"
+
+	mkdir "$pathcomp" || lasterr=$?
+
+	if test ! -d "$pathcomp"; then
+	  errstatus=$lasterr
+	else
+	  if test ! -z "$dirmode"; then
+	     echo "chmod $dirmode $pathcomp"
+
+	     lasterr=""
+	     chmod "$dirmode" "$pathcomp" || lasterr=$?
+
+	     if test ! -z "$lasterr"; then
+	       errstatus=$lasterr
+	     fi
+	  fi
+	fi
+     fi
+
+     pathcomp="$pathcomp/"
+   done
+done
+
+exit $errstatus
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 3
+# End:
+# mkinstalldirs ends here


Property changes on: experimental/j/Elphel333/rtp/daemon/rtp/mkinstalldirs
___________________________________________________________________
Name: svn:executable
   + 

Added: experimental/j/Elphel333/rtp/daemon/rtp/net_udp.c
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/net_udp.c	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/net_udp.c	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,967 @@
+/*
+ * FILE:     net_udp.c
+ * AUTHOR:   Colin Perkins 
+ * MODIFIED: Orion Hodson & Piers O'Hanlon
+ * 
+ * Copyright (c) 1998-2000 University College London
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, is permitted provided that the following conditions 
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by the Computer Science
+ *      Department at University College London
+ * 4. Neither the name of the University nor of the Department may be used
+ *    to endorse or promote products derived from this software without
+ *    specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/* If this machine supports IPv6 the symbol HAVE_IPv6 should */
+/* be defined in either config_unix.h or config_win32.h. The */
+/* appropriate system header files should also be included   */
+/* by those files.                                           */
+
+#include "config_unix.h"
+#include "config_win32.h"
+#include "debug.h"
+#include "memory.h"
+#include "inet_pton.h"
+#include "inet_ntop.h"
+#include "vsnprintf.h"
+#include "net_udp.h"
+
+#ifdef NEED_ADDRINFO_H
+#include "addrinfo.h"
+#endif
+
+#define IN_BROADCAST(i)    ( (((uint32_t)(i) & __IPADDR(0x000000ff)) == __IPADDR(0xff))   || \
+			     (((uint32_t)(i) & __IPADDR(0x0000ffff)) == __IPADDR(0xffff)) || \
+			     (((uint32_t)(i) & __IPADDR(0x00ffffff)) == __IPADDR(0xffffff)) )
+
+#define IPv4	4
+#define IPv6	6
+
+#ifdef WIN2K_IPV6
+const struct	in6_addr	in6addr_any = {IN6ADDR_ANY_INIT};
+#endif
+
+/* This is pretty nasty but it's the simplest way to get round */
+/* the Detexis bug that means their MUSICA IPv6 stack uses     */
+/* IPPROTO_IP instead of IPPROTO_IPV6 in setsockopt calls      */
+/* We also need to define in6addr_any */
+#ifdef  MUSICA_IPV6
+#define	IPPROTO_IPV6	IPPROTO_IP
+struct	in6_addr	in6addr_any = {IN6ADDR_ANY_INIT};
+
+/* These DEF's are required as MUSICA's winsock6.h causes a clash with some of the 
+ * standard ws2tcpip.h definitions (eg struct in_addr6).
+ * Note: winsock6.h defines AF_INET6 as 24 NOT 23 as in winsock2.h - I have left it
+ * set to the MUSICA value as this is used in some of their function calls. 
+ */
+//#define AF_INET6        23
+#define IP_MULTICAST_LOOP      11 /*set/get IP multicast loopback */
+#define	IP_MULTICAST_IF		9 /* set/get IP multicast i/f  */
+#define	IP_MULTICAST_TTL       10 /* set/get IP multicast ttl */
+#define	IP_MULTICAST_LOOP      11 /*set/get IP multicast loopback */
+#define	IP_ADD_MEMBERSHIP      12 /* add an IP group membership */
+#define	IP_DROP_MEMBERSHIP     13/* drop an IP group membership */
+
+#define IN6_IS_ADDR_UNSPECIFIED(a) (((a)->s6_addr32[0] == 0) && \
+									((a)->s6_addr32[1] == 0) && \
+									((a)->s6_addr32[2] == 0) && \
+									((a)->s6_addr32[3] == 0))
+struct ip_mreq {
+	struct in_addr imr_multiaddr;	/* IP multicast address of group */
+	struct in_addr imr_interface;	/* local IP address of interface */
+};
+#endif
+
+#ifndef INADDR_NONE
+#define INADDR_NONE 0xffffffff
+#endif
+
+struct socket_udp_ {
+	int	 	 mode;	/* IPv4 or IPv6 */
+        char	        *addr;
+	uint16_t	 rx_port;
+	uint16_t	 tx_port;
+	ttl_t	 	 ttl;
+	fd_t	 	 fd;
+	struct in_addr	 addr4;
+	struct in_addr	 iface4_addr;
+#ifdef HAVE_IPv6
+	struct in6_addr	 addr6;
+#endif /* HAVE_IPv6 */
+};
+
+#ifdef WIN32
+/* Want to use both Winsock 1 and 2 socket options, but since
+* IPv6 support requires Winsock 2 we have to add own backwards
+* compatibility for Winsock 1.
+*/
+#define SETSOCKOPT winsock_versions_setsockopt
+#else
+#define SETSOCKOPT setsockopt
+#endif /* WIN32 */
+
+/*****************************************************************************/
+/* Support functions...                                                      */
+/*****************************************************************************/
+
+static void
+socket_error(const char *msg, ...)
+{
+	char		buffer[255];
+	uint32_t	blen = sizeof(buffer) / sizeof(buffer[0]);
+	va_list		ap;
+
+#ifdef WIN32
+#define WSERR(x) {#x,x}
+	struct wse {
+		char  errname[20];
+		int my_errno;
+	};
+	struct wse ws_errs[] = {
+		WSERR(WSANOTINITIALISED), WSERR(WSAENETDOWN),     WSERR(WSAEACCES),
+		WSERR(WSAEINVAL),         WSERR(WSAEINTR),        WSERR(WSAEINPROGRESS),
+		WSERR(WSAEFAULT),         WSERR(WSAENETRESET),    WSERR(WSAENOBUFS),
+		WSERR(WSAENOTCONN),       WSERR(WSAENOTSOCK),     WSERR(WSAEOPNOTSUPP),
+		WSERR(WSAESHUTDOWN),      WSERR(WSAEWOULDBLOCK),  WSERR(WSAEMSGSIZE),
+		WSERR(WSAEHOSTUNREACH),   WSERR(WSAECONNABORTED), WSERR(WSAECONNRESET),
+		WSERR(WSAEADDRNOTAVAIL),  WSERR(WSAEAFNOSUPPORT), WSERR(WSAEDESTADDRREQ),
+		WSERR(WSAENETUNREACH),    WSERR(WSAETIMEDOUT),    WSERR(0)
+	};
+	
+	int i, e = WSAGetLastError();
+	i = 0;
+	while(ws_errs[i].my_errno && ws_errs[i].my_errno != e) {
+		i++;
+	}
+	va_start(ap, msg);
+	_vsnprintf(buffer, blen, msg, ap);
+	va_end(ap);
+	printf("ERROR: %s, (%d - %s)\n", msg, e, ws_errs[i].errname);
+#else
+	uint32_t retlen;
+	va_start(ap, msg);
+	retlen = vsnprintf(buffer, blen, msg, ap);
+	va_end(ap);
+	blen -= retlen;
+	snprintf(buffer + retlen, blen, ":%s", strerror(errno));
+	rtp_message(LOG_ALERT, buffer);
+#endif
+}
+
+#ifdef WIN32
+/* ws2tcpip.h defines these constants with different values from
+* winsock.h so files that use winsock 2 values but try to use 
+* winsock 1 fail.  So what was the motivation in changing the
+* constants ?
+*/
+#define WS1_IP_MULTICAST_IF     2 /* set/get IP multicast interface   */
+#define WS1_IP_MULTICAST_TTL    3 /* set/get IP multicast timetolive  */
+#define WS1_IP_MULTICAST_LOOP   4 /* set/get IP multicast loopback    */
+#define WS1_IP_ADD_MEMBERSHIP   5 /* add  an IP group membership      */
+#define WS1_IP_DROP_MEMBERSHIP  6 /* drop an IP group membership      */
+
+/* winsock_versions_setsockopt tries 1 winsock version of option 
+* optname and then winsock 2 version if that failed.
+*/
+
+static int
+winsock_versions_setsockopt(SOCKET s, int level, int optname, const char FAR * optval, int optlen)
+{
+	int success = -1;
+	switch (optname) {
+	case IP_MULTICAST_IF:
+		success = setsockopt(s, level, WS1_IP_MULTICAST_IF, optval, optlen);
+		break;
+	case IP_MULTICAST_TTL:
+		success = setsockopt(s, level, WS1_IP_MULTICAST_TTL, optval, optlen);
+		break;
+	case IP_MULTICAST_LOOP:
+		success = setsockopt(s, level, WS1_IP_MULTICAST_LOOP, optval, optlen);
+		break;
+	case IP_ADD_MEMBERSHIP: 
+		success = setsockopt(s, level, WS1_IP_ADD_MEMBERSHIP, optval, optlen);
+		break;
+	case IP_DROP_MEMBERSHIP: 
+		success = setsockopt(s, level, WS1_IP_DROP_MEMBERSHIP, optval, optlen);
+		break;
+	}
+	if (success != -1) {
+		return success;
+	}
+	return setsockopt(s, level, optname, optval, optlen);
+}
+#endif
+
+#if defined(NEED_INET_ATON) || !defined(HAVE_INET_ATON)
+#ifdef NEED_INET_ATON_STATIC
+static 
+#endif
+int inet_aton(const char *name, struct in_addr *addr)
+{
+	addr->s_addr = inet_addr(name);
+	return (addr->s_addr != (in_addr_t) INADDR_NONE);
+}
+#endif
+
+#ifdef NEED_IN6_IS_ADDR_MULTICAST
+#define IN6_IS_ADDR_MULTICAST(addr) ((addr)->s6_addr[0] == 0xffU)
+#endif
+
+#if defined(NEED_IN6_IS_ADDR_UNSPECIFIED) && defined(MUSICA_IPV6)
+#define IN6_IS_ADDR_UNSPECIFIED(addr) IS_UNSPEC_IN6_ADDR(*addr)
+#endif
+
+
+
+/*****************************************************************************/
+/* IPv4 specific functions...                                                */
+/*****************************************************************************/
+
+static int udp_addr_valid4(const char *dst)
+{
+        struct in_addr addr4;
+	struct hostent *h;
+
+	if (inet_pton(AF_INET, dst, &addr4)) {
+		return TRUE;
+	} 
+
+	h = gethostbyname(dst);
+	if (h != NULL) {
+		return TRUE;
+	}
+	socket_error("Can't resolve IP address for %s", dst);
+
+        return FALSE;
+}
+
+static socket_udp *udp_init4(const char *addr, const char *iface, uint16_t rx_port, uint16_t tx_port, int ttl)
+{
+	int                 	 reuse = 1;
+//int			brdcast= 1;
+	struct sockaddr_in  	 s_in;
+#ifdef WIN32
+	int recv_buf_size = 65536;
+#endif
+	socket_udp         	*s = (socket_udp *)malloc(sizeof(socket_udp));
+	s->mode    = IPv4;
+	s->addr    = NULL;
+	s->rx_port = rx_port;
+	s->tx_port = tx_port;
+	s->ttl     = ttl;
+	if (inet_pton(AF_INET, addr, &s->addr4) != 1) {
+		struct hostent *h = gethostbyname(addr);
+		if (h == NULL) {
+			socket_error("Can't resolve IP address for %s", addr);
+                        free(s);
+			return NULL;
+		}
+		memcpy(&(s->addr4), h->h_addr_list[0], sizeof(s->addr4));
+	}
+	if (iface != NULL) {
+		if (inet_pton(AF_INET, iface, &s->iface4_addr) != 1) {
+			rtp_message(LOG_ERR, "Illegal interface specification");
+                        free(s);
+			return NULL;
+		}
+	} else {
+		s->iface4_addr.s_addr = 0;
+	}
+	s->fd = socket(AF_INET, SOCK_DGRAM, 0);
+	if (s->fd < 0) {
+		socket_error("socket");
+		free(s);
+		return NULL;
+	}
+#ifdef WIN32
+	if (SETSOCKOPT(s->fd, SOL_SOCKET, SO_RCVBUF, (char *)&recv_buf_size, sizeof(int)) != 0) {
+	  socket_error("setsockopt SO_RCVBUF");
+	  close(s->fd);
+	  free(s);
+	  return NULL;
+	}
+#endif
+	
+	if (SETSOCKOPT(s->fd, SOL_SOCKET, SO_REUSEADDR, (char *) &reuse, sizeof(reuse)) != 0) {
+		socket_error("setsockopt SO_REUSEADDR");
+		close(s->fd);
+		free(s);
+		return NULL;
+	}
+#ifdef SO_REUSEPORT
+	if (SETSOCKOPT(s->fd, SOL_SOCKET, SO_REUSEPORT, (char *) &reuse, sizeof(reuse)) != 0) {
+	  close(s->fd);
+	  free(s);
+		socket_error("setsockopt SO_REUSEPORT");
+		return NULL;
+	}
+#endif
+// for UDP nochecksum on Linux for Elphel Camera 333
+	if (SETSOCKOPT(s->fd, SOL_SOCKET, SO_NO_CHECK, (char *) &reuse, sizeof(reuse)) != 0) {
+	  close(s->fd);
+	  free(s);
+		socket_error("setsockopt SO_NO_CHECK");
+		return NULL;
+	}
+
+
+	s_in.sin_family      = AF_INET;
+	s_in.sin_addr.s_addr = INADDR_ANY;
+	s_in.sin_port        = htons(rx_port);
+	if (bind(s->fd, (struct sockaddr *) &s_in, sizeof(s_in)) != 0) {
+		socket_error("bind: port %d", rx_port);
+		close(s->fd);
+		free(s);
+		return NULL;
+	}
+//	if (IN_BROADCAST(ntohl(s->addr4.s_addr)) && !IN_MULTICAST(ntohl(s->addr4.s_addr)) ) {
+       
+//          if (SETSOCKOPT(s->fd, SOL_SOCKET, SO_BROADCAST, (char *) &brdcast, sizeof(brdcast)) != 0) {
+//                     socket_error("setsockopt SO_BROADCAST");
+//                     close(s->fd);
+//                     free(s);
+//                   return NULL;
+//              }
+//
+
+	if (IN_MULTICAST(ntohl(s->addr4.s_addr))) {
+		char            loop = 1;
+		struct ip_mreq  imr;
+		
+		imr.imr_multiaddr.s_addr = s->addr4.s_addr;
+		imr.imr_interface.s_addr = s->iface4_addr.s_addr;
+		
+		if (SETSOCKOPT(s->fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *) &imr, sizeof(struct ip_mreq)) != 0) {
+			socket_error("setsockopt IP_ADD_MEMBERSHIP");
+			close(s->fd);
+			free(s);
+			return NULL;
+		}
+#ifndef WIN32
+		if (SETSOCKOPT(s->fd, IPPROTO_IP, IP_MULTICAST_LOOP, &loop, sizeof(loop)) != 0) {
+			socket_error("setsockopt IP_MULTICAST_LOOP");
+	  close(s->fd);
+	  free(s);
+			return NULL;
+		}
+#endif
+		if (SETSOCKOPT(s->fd, IPPROTO_IP, IP_MULTICAST_TTL, (char *) &s->ttl, sizeof(s->ttl)) != 0) {
+			socket_error("setsockopt IP_MULTICAST_TTL");
+			close(s->fd);
+			free(s);
+			return NULL;
+		}
+		if (s->iface4_addr.s_addr != 0) {
+			if (SETSOCKOPT(s->fd, IPPROTO_IP, IP_MULTICAST_IF, (char *) &s->iface4_addr, sizeof(s->iface4_addr)) != 0) {
+			  close(s->fd);
+			  free(s);
+				socket_error("setsockopt IP_MULTICAST_IF");
+				return NULL;
+			}
+		}
+	}
+        s->addr = strdup(addr);
+	return s;
+}
+
+static void udp_exit4(socket_udp *s)
+{
+	if (IN_MULTICAST(ntohl(s->addr4.s_addr))) {
+		struct ip_mreq  imr;
+		imr.imr_multiaddr.s_addr = s->addr4.s_addr;
+		if (s->iface4_addr.s_addr != 0) {
+		  imr.imr_interface.s_addr = s->iface4_addr.s_addr;
+		} else {
+		  imr.imr_interface.s_addr = INADDR_ANY;
+		}
+		if (SETSOCKOPT(s->fd, IPPROTO_IP, IP_DROP_MEMBERSHIP, (char *) &imr, sizeof(struct ip_mreq)) != 0) {
+			socket_error("setsockopt IP_DROP_MEMBERSHIP");
+			abort();
+		}
+		rtp_message(LOG_INFO,  "Dropped membership of multicast group");
+	}
+	close(s->fd);
+        free(s->addr);
+	free(s);
+}
+
+static int udp_send4(socket_udp *s, uint8_t *buffer, int buflen)
+{
+	struct sockaddr_in	s_in;
+	
+	ASSERT(s != NULL);
+	ASSERT(s->mode == IPv4);
+	ASSERT(buffer != NULL);
+	ASSERT(buflen > 0);
+	
+	s_in.sin_family      = AF_INET;
+	s_in.sin_addr.s_addr = s->addr4.s_addr;
+	s_in.sin_port        = htons(s->tx_port);
+	return sendto(s->fd, buffer, buflen, 0, (struct sockaddr *) &s_in, sizeof(s_in));
+}
+
+#ifndef _WIN32
+static int udp_send_iov4(socket_udp *s, struct iovec *iov, int count)
+{
+	struct sockaddr_in	s_in;
+	struct msghdr 		msg;
+	
+	ASSERT(s != NULL);
+	ASSERT(s->mode == IPv4);
+	ASSERT(iov != NULL);
+	ASSERT(count > 0);
+	
+	s_in.sin_family      = AF_INET;
+	s_in.sin_addr.s_addr = s->addr4.s_addr;
+	s_in.sin_port        = htons(s->tx_port);
+
+	memset(&msg, 0, sizeof(msg));
+	msg.msg_name 		 = (void *)&s_in;
+	msg.msg_namelen 	 = sizeof(s_in);
+	msg.msg_iov 		 = iov;
+	msg.msg_iovlen 		 = count;
+
+	return sendmsg(s->fd, &msg, 0);
+}
+#endif
+
+static char *udp_host_addr4(void)
+{
+  char    		 hname[MAXHOSTNAMELEN];
+  struct hostent 		*hent;
+  struct in_addr  	 iaddr;
+	
+	if (gethostname(hname, MAXHOSTNAMELEN) != 0) {
+		rtp_message(LOG_ERR, "Cannot get hostname!");
+		abort();
+	}
+	hent = gethostbyname(hname);
+	if (hent == NULL) {
+		socket_error("Can't resolve IP address for %s", hname);
+		return NULL;
+	}
+	ASSERT(hent->h_addrtype == AF_INET);
+	memcpy(&iaddr.s_addr, hent->h_addr, sizeof(iaddr.s_addr));
+	strncpy(hname, inet_ntoa(iaddr), MAXHOSTNAMELEN);
+	return xstrdup(hname);
+}
+
+/*****************************************************************************/
+/* IPv6 specific functions...                                                */
+/*****************************************************************************/
+
+static int udp_addr_valid6(const char *dst)
+{
+#ifdef HAVE_IPv6
+        struct in6_addr addr6;
+	switch (inet_pton(AF_INET6, dst, &addr6)) {
+        case 1:  
+                return TRUE;
+                break;
+        case 0: 
+                return FALSE;
+                break;
+        case -1: 
+                rtp_message(LOG_ERR, "inet_pton failed");
+                errno = 0;
+        }
+#endif /* HAVE_IPv6 */
+        UNUSED(dst);
+        return FALSE;
+}
+
+static socket_udp *udp_init6(const char *addr, const char *iface, uint16_t rx_port, uint16_t tx_port, int ttl)
+{
+#ifdef HAVE_IPv6
+	int                 reuse = 1;
+	struct sockaddr_in6 s_in;
+	socket_udp         *s = (socket_udp *) malloc(sizeof(socket_udp));
+	s->mode    = IPv6;
+	s->addr    = NULL;
+	s->rx_port = rx_port;
+	s->tx_port = tx_port;
+	s->ttl     = ttl;
+	
+	if (iface != NULL) {
+		debug_msg("Not yet implemented\n");
+		abort();
+	}
+
+	if (inet_pton(AF_INET6, addr, &s->addr6) != 1) {
+		/* We should probably try to do a DNS lookup on the name */
+		/* here, but I'm trying to get the basics going first... */
+		debug_msg("IPv6 address conversion failed\n");
+                free(s);
+		return NULL;	
+	}
+	s->fd = socket(AF_INET6, SOCK_DGRAM, 0);
+	if (s->fd < 0) {
+		socket_error("socket");
+		return NULL;
+	}
+	if (SETSOCKOPT(s->fd, SOL_SOCKET, SO_REUSEADDR, (char *) &reuse, sizeof(reuse)) != 0) {
+		socket_error("setsockopt SO_REUSEADDR");
+		return NULL;
+	}
+#ifdef SO_REUSEPORT
+	if (SETSOCKOPT(s->fd, SOL_SOCKET, SO_REUSEPORT, (char *) &reuse, sizeof(reuse)) != 0) {
+		socket_error("setsockopt SO_REUSEPORT");
+		return NULL;
+	}
+#endif
+	
+	memset((char *)&s_in, 0, sizeof(s_in));
+	s_in.sin6_family = AF_INET6;
+	s_in.sin6_port   = htons(rx_port);
+#ifdef HAVE_SIN6_LEN
+	s_in.sin6_len    = sizeof(s_in);
+#endif
+	s_in.sin6_addr = in6addr_any;
+	if (bind(s->fd, (struct sockaddr *) &s_in, sizeof(s_in)) != 0) {
+		socket_error("bind");
+		return NULL;
+	}
+	
+	if (IN6_IS_ADDR_MULTICAST(&(s->addr6))) {
+		unsigned int      loop = 1;
+		struct ipv6_mreq  imr;
+#ifdef MUSICA_IPV6
+		imr.i6mr_interface = 1;
+		imr.i6mr_multiaddr = s->addr6;
+#else
+		imr.ipv6mr_multiaddr = s->addr6;
+		imr.ipv6mr_interface = 0;
+#endif
+		
+		if (SETSOCKOPT(s->fd, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, (char *) &imr, sizeof(struct ipv6_mreq)) != 0) {
+			socket_error("setsockopt IPV6_ADD_MEMBERSHIP");
+			return NULL;
+		}
+		
+		if (SETSOCKOPT(s->fd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, (char *) &loop, sizeof(loop)) != 0) {
+			socket_error("setsockopt IPV6_MULTICAST_LOOP");
+			return NULL;
+		}
+		if (SETSOCKOPT(s->fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, (char *) &ttl, sizeof(ttl)) != 0) {
+			socket_error("setsockopt IPV6_MULTICAST_HOPS");
+			return NULL;
+		}
+	}
+
+	ASSERT(s != NULL);
+
+        s->addr = strdup(addr);
+	return s;
+#else
+	UNUSED(addr);
+	UNUSED(iface);
+	UNUSED(rx_port);
+	UNUSED(tx_port);
+	UNUSED(ttl);
+	return NULL;
+#endif
+}
+
+static void udp_exit6(socket_udp *s)
+{
+#ifdef HAVE_IPv6
+	if (IN6_IS_ADDR_MULTICAST(&(s->addr6))) {
+		struct ipv6_mreq  imr;
+#ifdef MUSICA_IPV6
+		imr.i6mr_interface = 1;
+		imr.i6mr_multiaddr = s->addr6;
+#else
+		imr.ipv6mr_multiaddr = s->addr6;
+		imr.ipv6mr_interface = 0;
+#endif
+		
+		if (SETSOCKOPT(s->fd, IPPROTO_IPV6, IPV6_DROP_MEMBERSHIP, (char *) &imr, sizeof(struct ipv6_mreq)) != 0) {
+			socket_error("setsockopt IPV6_DROP_MEMBERSHIP");
+			abort();
+		}
+	}
+	close(s->fd);
+        free(s->addr);
+	free(s);
+#else
+	UNUSED(s);
+#endif  /* HAVE_IPv6 */
+}
+
+static int udp_send6(socket_udp *s, uint8_t *buffer, int buflen)
+{
+#ifdef HAVE_IPv6
+	struct sockaddr_in6	s_in;
+	
+	ASSERT(s != NULL);
+	ASSERT(s->mode == IPv6);
+	ASSERT(buffer != NULL);
+	ASSERT(buflen > 0);
+	
+	memset((char *)&s_in, 0, sizeof(s_in));
+	s_in.sin6_family = AF_INET6;
+	s_in.sin6_addr   = s->addr6;
+	s_in.sin6_port   = htons(s->tx_port);
+#ifdef HAVE_SIN6_LEN
+	s_in.sin6_len    = sizeof(s_in);
+#endif
+	return sendto(s->fd, buffer, buflen, 0, (struct sockaddr *) &s_in, sizeof(s_in));
+#else
+	UNUSED(s);
+	UNUSED(buffer);
+	UNUSED(buflen);
+	return -1;
+#endif
+}
+
+#ifndef _WIN32
+static int udp_send_iov6(socket_udp *s, struct iovec *iov, int count)
+{
+#ifdef HAVE_IPv6
+	struct sockaddr_in6	s_in;
+	struct msghdr msg;
+	
+	ASSERT(s != NULL);
+	ASSERT(s->mode == IPv6);
+	
+	memset((char *)&s_in, 0, sizeof(s_in));
+	s_in.sin6_family = AF_INET6;
+	s_in.sin6_addr   = s->addr6;
+	s_in.sin6_port   = htons(s->tx_port);
+#ifdef HAVE_SIN6_LEN
+	s_in.sin6_len    = sizeof(s_in);
+#endif
+
+	msg.msg_name 		 = &s_in;
+	msg.msg_namelen 	 = sizeof(s_in);
+	msg.msg_iov 		 = iov;
+	msg.msg_iovlen 		 = count;
+	msg.msg_control 	 = NULL;
+	msg.msg_controllen 	 = 0;
+	msg.msg_flags 		 = 0;
+
+	return sendmsg(s->fd, &msg, 0);
+#else
+	UNUSED(s);
+	UNUSED(iov);
+	UNUSED(count);
+	return -1;
+#endif
+}
+#endif
+
+static char *udp_host_addr6(socket_udp *s)
+{
+#ifdef HAVE_IPv6
+	char		 hname[MAXHOSTNAMELEN];
+	int 			 gai_err, newsock;
+	struct addrinfo 	 hints, *ai;
+	struct sockaddr_in6 	 local, addr6;
+	int len = sizeof(local), result = 0;
+
+	newsock=socket(AF_INET6, SOCK_DGRAM,0);
+    memset ((char *)&addr6, 0, len);
+    addr6.sin6_family = AF_INET6;
+#ifdef HAVE_SIN6_LEN
+    addr6.sin6_len    = len;
+#endif
+    bind (newsock, (struct sockaddr *) &addr6, len);
+    addr6.sin6_addr = s->addr6;
+    addr6.sin6_port = htons (s->rx_port);
+    connect (newsock, (struct sockaddr *) &addr6, len);
+
+    memset ((char *)&local, 0, len);
+	if ((result = getsockname(newsock,(struct sockaddr *)&local, &len)) < 0){
+		local.sin6_addr = in6addr_any;
+		local.sin6_port = 0;
+		debug_msg("getsockname failed\n");
+	}
+
+	close (newsock);
+
+	if (IN6_IS_ADDR_UNSPECIFIED(&local.sin6_addr) || IN6_IS_ADDR_MULTICAST(&local.sin6_addr)) {
+		if (gethostname(hname, MAXHOSTNAMELEN) != 0) {
+			debug_msg("gethostname failed\n");
+			abort();
+		}
+		
+		hints.ai_protocol  = 0;
+		hints.ai_flags     = 0;
+		hints.ai_family    = AF_INET6;
+		hints.ai_socktype  = SOCK_DGRAM;
+		hints.ai_addrlen   = 0;
+		hints.ai_canonname = NULL;
+		hints.ai_addr      = NULL;
+		hints.ai_next      = NULL;
+
+		if ((gai_err = getaddrinfo(hname, NULL, &hints, &ai))) {
+			debug_msg("getaddrinfo: %s: %s\n", hname, gai_strerror(gai_err));
+			abort();
+		}
+		
+		if (inet_ntop(AF_INET6, &(((struct sockaddr_in6 *)(ai->ai_addr))->sin6_addr), hname, MAXHOSTNAMELEN) == NULL) {
+			debug_msg("inet_ntop: %s: \n", hname);
+			abort();
+		}
+		freeaddrinfo(ai);
+		return xstrdup(hname);
+	}
+	if (inet_ntop(AF_INET6, &local.sin6_addr, hname, MAXHOSTNAMELEN) == NULL) {
+		debug_msg("inet_ntop: %s: \n", hname);
+		abort();
+	}
+	return xstrdup(hname);
+#else  /* HAVE_IPv6 */
+	UNUSED(s);
+	return xstrdup("::");	/* The unspecified address... */
+#endif /* HAVE_IPv6 */
+}
+	
+/*****************************************************************************/
+/* Generic functions, which call the appropriate protocol specific routines. */
+/*****************************************************************************/
+
+/**
+ * udp_addr_valid:
+ * @addr: string representation of IPv4 or IPv6 network address.
+ *
+ * Returns TRUE if @addr is valid, FALSE otherwise.
+ **/
+
+int udp_addr_valid(const char *addr)
+{
+        return udp_addr_valid4(addr) | udp_addr_valid6(addr);
+}
+
+/**
+ * udp_init:
+ * @addr: character string containing an IPv4 or IPv6 network address.
+ * @rx_port: receive port.
+ * @tx_port: transmit port.
+ * @ttl: time-to-live value for transmitted packets.
+ *
+ * Creates a session for sending and receiving UDP datagrams over IP
+ * networks. 
+ *
+ * Returns: a pointer to a valid socket_udp structure on success, NULL otherwise.
+ **/
+socket_udp *udp_init(const char *addr, uint16_t rx_port, uint16_t tx_port, int ttl)
+{
+	return udp_init_if(addr, NULL, rx_port, tx_port, ttl);
+}
+
+/**
+ * udp_init_if:
+ * @addr: character string containing an IPv4 or IPv6 network address.
+ * @iface: character string containing an interface name.
+ * @rx_port: receive port.
+ * @tx_port: transmit port.
+ * @ttl: time-to-live value for transmitted packets.
+ *
+ * Creates a session for sending and receiving UDP datagrams over IP
+ * networks.  The session uses @iface as the interface to send and
+ * receive datagrams on.
+ * 
+ * Return value: a pointer to a socket_udp structure on success, NULL otherwise.
+ **/
+socket_udp *udp_init_if(const char *addr, const char *iface, uint16_t rx_port, uint16_t tx_port, int ttl)
+{
+	socket_udp *res;
+	
+	if (strchr(addr, ':') == NULL) {
+		res = udp_init4(addr, iface, rx_port, tx_port, ttl);
+	} else {
+		res = udp_init6(addr, iface, rx_port, tx_port, ttl);
+	}
+	return res;
+}
+
+/**
+ * udp_exit:
+ * @s: UDP session to be terminated.
+ *
+ * Closes UDP session.
+ * 
+ **/
+void udp_exit(socket_udp *s)
+{
+    switch(s->mode) {
+    case IPv4 : udp_exit4(s); break;
+    case IPv6 : udp_exit6(s); break;
+    default   : abort();
+    }
+}
+
+/**
+ * udp_send:
+ * @s: UDP session.
+ * @buffer: pointer to buffer to be transmitted.
+ * @buflen: length of @buffer.
+ * 
+ * Transmits a UDP datagram containing data from @buffer.
+ * 
+ * Return value: 0 on success, -1 on failure.
+ **/
+int udp_send(socket_udp *s, uint8_t *buffer, int buflen)
+{
+	switch (s->mode) {
+	case IPv4 : return udp_send4(s, buffer, buflen);
+	case IPv6 : return udp_send6(s, buffer, buflen);
+	default   : abort(); /* Yuk! */
+	}
+	return -1;
+}
+
+#ifndef _WIN32
+int udp_send_iov(socket_udp *s, struct iovec *iov, int count)
+{
+	switch (s->mode) {
+	case IPv4 : return udp_send_iov4(s, iov, count);
+	case IPv6 : return udp_send_iov6(s, iov, count);
+	default   : abort();
+	}
+	return -1;
+}
+#endif
+
+/**
+ * udp_recv:
+ * @s: UDP session.
+ * @buffer: buffer to read data into.
+ * @buflen: length of @buffer.
+ * 
+ * Reads from datagram queue associated with UDP session.
+ *
+ * Return value: number of bytes read, returns 0 if no data is available.
+ **/
+int udp_recv(socket_udp *s, uint8_t *buffer, int buflen)
+{
+	/* Reads data into the buffer, returning the number of bytes read.   */
+	/* If no data is available, this returns the value zero immediately. */
+	/* Note: since we don't care about the source address of the packet  */
+	/* we receive, this function becomes protocol independent.           */
+	int		len;
+
+	ASSERT(buffer != NULL);
+	ASSERT(buflen > 0);
+
+	len = recvfrom(s->fd, buffer, buflen, 0, 0, 0);
+	if (len > 0) {
+		return len;
+	}
+	if (errno != ECONNREFUSED) {
+		socket_error("recvfrom");
+	}
+	return 0;
+}
+
+static fd_set	rfd;
+static fd_t	max_fd;
+
+/**
+ * udp_fd_zero:
+ * 
+ * Clears file descriptor from set associated with UDP sessions (see select(2)).
+ * 
+ **/
+void udp_fd_zero(void)
+{
+	FD_ZERO(&rfd);
+	max_fd = 0;
+}
+
+/**
+ * udp_fd_set:
+ * @s: UDP session.
+ * 
+ * Adds file descriptor associated of @s to set associated with UDP sessions.
+ **/
+void udp_fd_set(socket_udp *s)
+{
+	FD_SET(s->fd, &rfd);
+	if (s->fd > (fd_t)max_fd) {
+		max_fd = s->fd;
+	}
+}
+
+/**
+ * udp_fd_isset:
+ * @s: UDP session.
+ * 
+ * Checks if file descriptor associated with UDP session is ready for
+ * reading.  This function should be called after udp_select().
+ *
+ * Returns: non-zero if set, zero otherwise.
+ **/
+int udp_fd_isset(socket_udp *s)
+{
+	return FD_ISSET(s->fd, &rfd);
+}
+
+/**
+ * udp_select:
+ * @timeout: maximum period to wait for data to arrive.
+ * 
+ * Waits for data to arrive for UDP sessions.
+ * 
+ * Return value: number of UDP sessions ready for reading.
+ **/
+int udp_select(struct timeval *timeout)
+{
+	return select(max_fd + 1, &rfd, NULL, NULL, timeout);
+}
+
+/**
+ * udp_host_addr:
+ * @s: UDP session.
+ * 
+ * Return value: character string containing network address
+ * associated with session @s.
+ **/
+char *udp_host_addr(socket_udp *s)
+{
+  if (s && s->mode == IPv6) {
+    return udp_host_addr6(s);
+  } 
+  return udp_host_addr4();
+}
+
+/**
+ * udp_fd:
+ * @s: UDP session.
+ * 
+ * This function allows applications to apply their own socketopt()'s
+ * and ioctl()'s to the UDP session.
+ * 
+ * Return value: file descriptor of socket used by session @s.
+ **/
+int udp_fd(socket_udp *s)
+{
+	if (s && s->fd > 0) {
+		return s->fd;
+	} 
+	return 0;
+}
+

Added: experimental/j/Elphel333/rtp/daemon/rtp/net_udp.h
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/net_udp.h	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/net_udp.h	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,69 @@
+/*
+ * FILE:    net_udp.h
+ * AUTHORS: Colin Perkins
+ * 
+ * Copyright (c) 1998-2000 University College London
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, is permitted provided that the following conditions 
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by the Computer Science
+ *      Department at University College London
+ * 4. Neither the name of the University nor of the Department may be used
+ *    to endorse or promote products derived from this software without
+ *    specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _NET_UDP
+#define _NET_UDP
+#include "rtp.h"
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+
+int         udp_addr_valid(const char *addr);
+socket_udp *udp_init(const char *addr, uint16_t rx_port, uint16_t tx_port, int ttl);
+socket_udp *udp_init_if(const char *addr, const char *iface, uint16_t rx_port, uint16_t tx_port, int ttl);
+void        udp_exit(socket_udp *s);
+
+int         udp_send(socket_udp *s, uint8_t *buffer, int buflen);
+#ifndef _WIN32
+int udp_send_iov(socket_udp *s, struct iovec *iov, int count);
+#endif
+int         udp_recv(socket_udp *s, uint8_t *buffer, int buflen);
+
+char *udp_host_addr(socket_udp *s);
+int         udp_fd(socket_udp *s);
+
+int         udp_select(struct timeval *timeout);
+void        udp_fd_zero(void);
+void        udp_fd_set(socket_udp *s);
+int         udp_fd_isset(socket_udp *s);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
+

Added: experimental/j/Elphel333/rtp/daemon/rtp/ntp.c
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/ntp.c	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/ntp.c	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,32 @@
+/*
+ * FILE:    ntp.h
+ * AUTHOR:  O.Hodson
+ * 
+ * NTP utility functions to make rtp and rtp round time calculation
+ * a little less painful.
+ *
+ * Copyright (c) 2000 University College London
+ * All rights reserved.
+ *
+ * $Id: ntp.c,v 1.1.1.1 2005/03/18 09:17:52 elphel Exp $
+ */
+
+#include "config_unix.h"
+#include "config_win32.h"
+#include "gettimeofday.h"
+
+#include "ntp.h"
+
+#define SECS_BETWEEN_1900_1970 2208988800u
+
+void 
+ntp64_time(uint32_t *ntp_sec, uint32_t *ntp_frac)
+{
+        struct timeval now;
+
+        gettimeofday(&now, NULL);
+
+        /* NB ntp_frac is in units of 1 / (2^32 - 1) secs. */
+        *ntp_sec  = now.tv_sec + SECS_BETWEEN_1900_1970;
+        *ntp_frac = (now.tv_usec << 12) + (now.tv_usec << 8) - ((now.tv_usec * 3650) >> 6);
+}

Added: experimental/j/Elphel333/rtp/daemon/rtp/ntp.h
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/ntp.h	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/ntp.h	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,33 @@
+/*
+ * FILE:    ntp.h
+ * AUTHOR:  O.Hodson
+ * 
+ * NTP utility functions to make rtp and rtp round time calculation
+ * a little less painful.
+ *
+ * Copyright (c) 2000 University College London
+ * All rights reserved.
+ *
+ * $Id: ntp.h,v 1.1.1.1 2005/03/18 09:17:52 elphel Exp $
+ */
+
+#ifndef _NTP_H
+#define _NTP_H
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+        
+#define  ntp64_to_ntp32(ntp_sec, ntp_frac)          \
+               ((((ntp_sec)  & 0x0000ffff) << 16) | \
+                (((ntp_frac) & 0xffff0000) >> 16))
+
+#define  ntp32_sub(now, then) ((now) > (then)) ? ((now) - (then)) : (((now) - (then)) + 0x7fffffff)
+
+void     ntp64_time(uint32_t *ntp_sec, uint32_t *ntp_frac);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* _NTP_H */

Added: experimental/j/Elphel333/rtp/daemon/rtp/qfDES.c
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/qfDES.c	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/qfDES.c	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,927 @@
+/*****************************************************************************
+
+Saleem N. Bhatti
+February 1993
+
+Patch for Intel/Linux courtesy of Mark Handley & George Pavlou
+Added 2 August 1996, Saleem
+*****************************************************************************/
+
+#include "config_unix.h"
+#include "config_win32.h"
+#include "qfDES.h"
+#include "crypt_random.h"
+
+typedef unsigned long Word;
+
+#define B00 0x80000000
+#define B01 0x40000000
+#define B02 0x20000000
+#define B03 0x10000000
+#define B04 0x08000000
+#define B05 0x04000000
+#define B06 0x02000000
+#define B07 0x01000000
+#define B08 0x00800000
+#define B09 0x00400000
+#define B10 0x00200000
+#define B11 0x00100000
+#define B12 0x00080000
+#define B13 0x00040000
+#define B14 0x00020000
+#define B15 0x00010000
+#define B16 0x00008000
+#define B17 0x00004000
+#define B18 0x00002000
+#define B19 0x00001000
+#define B20 0x00000800
+#define B21 0x00000400
+#define B22 0x00000200
+#define B23 0x00000100
+#define B24 0x00000080
+#define B25 0x00000040
+#define B26 0x00000020
+#define B27 0x00000010
+#define B28 0x00000008
+#define B29 0x00000004
+#define B30 0x00000002
+#define B31 0x00000001
+
+#define INITIAL_PERMUTATION_AUX(_i0, _i1, _o0, _o1) \
+{ \
+_o0 = _o1 = 0; \
+_o0 |= (_i1 & B25) << 25; /* 58 */ \
+_o0 |= (_i1 & B17) << 16; /* 50 */ \
+_o0 |= (_i1 & B09) <<  7; /* 42 */ \
+_o0 |= (_i1 & B01) >>  2; /* 34 */ \
+_o0 |= (_i0 & B25) << 21; /* 26 */ \
+_o0 |= (_i0 & B17) << 12; /* 18 */ \
+_o0 |= (_i0 & B09) <<  3; /* 10 */ \
+_o0 |= (_i0 & B01) >>  6; /*  2 */ \
+_o0 |= (_i1 & B27) << 19; /* 60 */ \
+_o0 |= (_i1 & B19) << 10; /* 52 */ \
+_o0 |= (_i1 & B11) <<  1; /* 44 */ \
+_o0 |= (_i1 & B03) >>  8; /* 36 */ \
+_o0 |= (_i0 & B27) << 15; /* 28 */ \
+_o0 |= (_i0 & B19) <<  6; /* 20 */ \
+_o0 |= (_i0 & B11) >>  3; /* 12 */ \
+_o0 |= (_i0 & B03) >> 12; /*  4 */ \
+_o0 |= (_i1 & B29) << 13; /* 62 */ \
+_o0 |= (_i1 & B21) <<  4; /* 54 */ \
+_o0 |= (_i1 & B13) >>  5; /* 46 */ \
+_o0 |= (_i1 & B05) >> 14; /* 38 */ \
+_o0 |= (_i0 & B29) <<  9; /* 30 */ \
+_o0 |= (_i0 & B21)      ; /* 22 */ \
+_o0 |= (_i0 & B13) >>  9; /* 14 */ \
+_o0 |= (_i0 & B05) >> 18; /*  6 */ \
+_o0 |= (_i1 & B31) <<  7; /* 64 */ \
+_o0 |= (_i1 & B23) >>  2; /* 56 */ \
+_o0 |= (_i1 & B15) >> 11; /* 48 */ \
+_o0 |= (_i1 & B07) >> 20; /* 40 */ \
+_o0 |= (_i0 & B31) <<  3; /* 32 */ \
+_o0 |= (_i0 & B23) >>  6; /* 24 */ \
+_o0 |= (_i0 & B15) >> 15; /* 16 */ \
+_o0 |= (_i0 & B07) >> 24; /*  8 */ \
+_o1 |= (_i1 & B24) << 24; /* 57 */ \
+_o1 |= (_i1 & B16) << 15; /* 49 */ \
+_o1 |= (_i1 & B08) <<  6; /* 41 */ \
+_o1 |= (_i1 & B00) >>  3; /* 33 */ \
+_o1 |= (_i0 & B24) << 20; /* 25 */ \
+_o1 |= (_i0 & B16) << 11; /* 17 */ \
+_o1 |= (_i0 & B08) <<  2; /*  9 */ \
+_o1 |= (_i0 & B00) >>  7; /*  1 */ \
+_o1 |= (_i1 & B26) << 18; /* 59 */ \
+_o1 |= (_i1 & B18) <<  9; /* 51 */ \
+_o1 |= (_i1 & B10)      ; /* 43 */ \
+_o1 |= (_i1 & B02) >>  9; /* 35 */ \
+_o1 |= (_i0 & B26) << 14; /* 27 */ \
+_o1 |= (_i0 & B18) <<  5; /* 19 */ \
+_o1 |= (_i0 & B10) >>  4; /* 11 */ \
+_o1 |= (_i0 & B02) >> 13; /*  3 */ \
+_o1 |= (_i1 & B28) << 12; /* 61 */ \
+_o1 |= (_i1 & B20) <<  3; /* 53 */ \
+_o1 |= (_i1 & B12) >>  6; /* 45 */ \
+_o1 |= (_i1 & B04) >> 15; /* 37 */ \
+_o1 |= (_i0 & B28) <<  8; /* 29 */ \
+_o1 |= (_i0 & B20) >>  1; /* 21 */ \
+_o1 |= (_i0 & B12) >> 10; /* 13 */ \
+_o1 |= (_i0 & B04) >> 19; /*  5 */ \
+_o1 |= (_i1 & B30) <<  6; /* 63 */ \
+_o1 |= (_i1 & B22) >>  3; /* 55 */ \
+_o1 |= (_i1 & B14) >> 12; /* 47 */ \
+_o1 |= (_i1 & B06) >> 21; /* 39 */ \
+_o1 |= (_i0 & B30) <<  2; /* 31 */ \
+_o1 |= (_i0 & B22) >>  7; /* 23 */ \
+_o1 |= (_i0 & B14) >> 16; /* 15 */ \
+_o1 |= (_i0 & B06) >> 25; /*  7 */ \
+}
+
+#define FINAL_PERMUTATION_AUX(_i0, _i1, _o0, _o1) \
+{ \
+_o0 = _o1 = 0; \
+_o0 |= (_i1 & B07) <<  7; /* 40 */ \
+_o0 |= (_i0 & B07) <<  6; /*  8 */ \
+_o0 |= (_i1 & B15) << 13; /* 48 */ \
+_o0 |= (_i0 & B15) << 12; /* 16 */ \
+_o0 |= (_i1 & B23) << 19; /* 56 */ \
+_o0 |= (_i0 & B23) << 18; /* 24 */ \
+_o0 |= (_i1 & B31) << 25; /* 64 */ \
+_o0 |= (_i0 & B31) << 24; /* 32 */ \
+_o0 |= (_i1 & B06) >>  2; /* 39 */ \
+_o0 |= (_i0 & B06) >>  3; /*  7 */ \
+_o0 |= (_i1 & B14) <<  4; /* 47 */ \
+_o0 |= (_i0 & B14) <<  3; /* 15 */ \
+_o0 |= (_i1 & B22) << 10; /* 55 */ \
+_o0 |= (_i0 & B22) <<  9; /* 23 */ \
+_o0 |= (_i1 & B30) << 16; /* 63 */ \
+_o0 |= (_i0 & B30) << 15; /* 31 */ \
+_o0 |= (_i1 & B05) >> 11; /* 38 */ \
+_o0 |= (_i0 & B05) >> 12; /*  6 */ \
+_o0 |= (_i1 & B13) >>  5; /* 46 */ \
+_o0 |= (_i0 & B13) >>  6; /* 14 */ \
+_o0 |= (_i1 & B21) <<  1; /* 54 */ \
+_o0 |= (_i0 & B21)      ; /* 22 */ \
+_o0 |= (_i1 & B29) <<  7; /* 62 */ \
+_o0 |= (_i0 & B29) <<  6; /* 30 */ \
+_o0 |= (_i1 & B04) >> 20; /* 37 */ \
+_o0 |= (_i0 & B04) >> 21; /*  5 */ \
+_o0 |= (_i1 & B12) >> 14; /* 45 */ \
+_o0 |= (_i0 & B12) >> 15; /* 13 */ \
+_o0 |= (_i1 & B20) >>  8; /* 53 */ \
+_o0 |= (_i0 & B20) >>  9; /* 21 */ \
+_o0 |= (_i1 & B28) >>  2; /* 61 */ \
+_o0 |= (_i0 & B28) >>  3; /* 29 */ \
+_o1 |= (_i1 & B03) <<  3; /* 36 */ \
+_o1 |= (_i0 & B03) <<  2; /*  4 */ \
+_o1 |= (_i1 & B11) <<  9; /* 44 */ \
+_o1 |= (_i0 & B11) <<  8; /* 12 */ \
+_o1 |= (_i1 & B19) << 15; /* 52 */ \
+_o1 |= (_i0 & B19) << 14; /* 20 */ \
+_o1 |= (_i1 & B27) << 21; /* 60 */ \
+_o1 |= (_i0 & B27) << 20; /* 28 */ \
+_o1 |= (_i1 & B02) >>  6; /* 35 */ \
+_o1 |= (_i0 & B02) >>  7; /*  3 */ \
+_o1 |= (_i1 & B10)      ; /* 43 */ \
+_o1 |= (_i0 & B10) >>  1; /* 11 */ \
+_o1 |= (_i1 & B18) <<  6; /* 51 */ \
+_o1 |= (_i0 & B18) <<  5; /* 19 */ \
+_o1 |= (_i1 & B26) << 12; /* 59 */ \
+_o1 |= (_i0 & B26) << 11; /* 27 */ \
+_o1 |= (_i1 & B01) >> 15; /* 34 */ \
+_o1 |= (_i0 & B01) >> 16; /*  2 */ \
+_o1 |= (_i1 & B09) >>  9; /* 42 */ \
+_o1 |= (_i0 & B09) >> 10; /* 10 */ \
+_o1 |= (_i1 & B17) >>  3; /* 50 */ \
+_o1 |= (_i0 & B17) >>  4; /* 18 */ \
+_o1 |= (_i1 & B25) <<  3; /* 58 */ \
+_o1 |= (_i0 & B25) <<  2; /* 26 */ \
+_o1 |= (_i1 & B00) >> 24; /* 33 */ \
+_o1 |= (_i0 & B00) >> 25; /*  1 */ \
+_o1 |= (_i1 & B08) >> 18; /* 41 */ \
+_o1 |= (_i0 & B08) >> 19; /*  9 */ \
+_o1 |= (_i1 & B16) >> 12; /* 49 */ \
+_o1 |= (_i0 & B16) >> 13; /* 17 */ \
+_o1 |= (_i1 & B24) >>  6; /* 57 */ \
+_o1 |= (_i0 & B24) >>  7; /* 25 */ \
+}
+
+/* 64b -> 2x28b */
+#define PC1_AUX(_i0, _i1, _o0, _o1) \
+{ \
+_o0 = _o1 = 0; \
+_o0 |= (_i1 & B24) << 24; /* 57 */ \
+_o0 |= (_i1 & B16) << 15; /* 49 */ \
+_o0 |= (_i1 & B08) <<  6; /* 41 */ \
+_o0 |= (_i1 & B00) >>  3; /* 33 */ \
+_o0 |= (_i0 & B24) << 20; /* 25 */ \
+_o0 |= (_i0 & B16) << 11; /* 17 */ \
+_o0 |= (_i0 & B08) <<  2; /*  9 */ \
+_o0 |= (_i0 & B00) >>  7; /*  1 */ \
+_o0 |= (_i1 & B25) << 17; /* 58 */ \
+_o0 |= (_i1 & B17) <<  8; /* 50 */ \
+_o0 |= (_i1 & B09) >>  1; /* 42 */ \
+_o0 |= (_i1 & B01) >> 10; /* 34 */ \
+_o0 |= (_i0 & B25) << 13; /* 26 */ \
+_o0 |= (_i0 & B17) <<  4; /* 18 */ \
+_o0 |= (_i0 & B09) >>  5; /* 10 */ \
+_o0 |= (_i0 & B01) >> 14; /*  2 */ \
+_o0 |= (_i1 & B26) << 10; /* 59 */ \
+_o0 |= (_i1 & B18) <<  1; /* 51 */ \
+_o0 |= (_i1 & B10) >>  8; /* 43 */ \
+_o0 |= (_i1 & B02) >> 17; /* 35 */ \
+_o0 |= (_i0 & B26) <<  6; /* 27 */ \
+_o0 |= (_i0 & B18) >>  3; /* 19 */ \
+_o0 |= (_i0 & B10) >> 12; /* 11 */ \
+_o0 |= (_i0 & B02) >> 21; /*  3 */ \
+_o0 |= (_i1 & B27) <<  3; /* 60 */ \
+_o0 |= (_i1 & B19) >>  6; /* 52 */ \
+_o0 |= (_i1 & B11) >> 15; /* 44 */ \
+_o0 |= (_i1 & B03) >> 24; /* 36 */ \
+_o1 |= (_i1 & B30) << 30; /* 63 */ \
+_o1 |= (_i1 & B22) << 21; /* 55 */ \
+_o1 |= (_i1 & B14) << 12; /* 47 */ \
+_o1 |= (_i1 & B06) <<  3; /* 39 */ \
+_o1 |= (_i0 & B30) << 26; /* 31 */ \
+_o1 |= (_i0 & B22) << 17; /* 23 */ \
+_o1 |= (_i0 & B14) <<  8; /* 15 */ \
+_o1 |= (_i0 & B06) >>  1; /*  7 */ \
+_o1 |= (_i1 & B29) << 21; /* 62 */ \
+_o1 |= (_i1 & B21) << 12; /* 54 */ \
+_o1 |= (_i1 & B13) <<  3; /* 46 */ \
+_o1 |= (_i1 & B05) >>  6; /* 38 */ \
+_o1 |= (_i0 & B29) << 17; /* 30 */ \
+_o1 |= (_i0 & B21) <<  8; /* 22 */ \
+_o1 |= (_i0 & B13) >>  1; /* 14 */ \
+_o1 |= (_i0 & B05) >> 10; /*  6 */ \
+_o1 |= (_i1 & B28) << 12; /* 61 */ \
+_o1 |= (_i1 & B20) <<  3; /* 53 */ \
+_o1 |= (_i1 & B12) >>  6; /* 45 */ \
+_o1 |= (_i1 & B04) >> 15; /* 37 */ \
+_o1 |= (_i0 & B28) <<  8; /* 29 */ \
+_o1 |= (_i0 & B20) >>  1; /* 21 */ \
+_o1 |= (_i0 & B12) >> 10; /* 13 */ \
+_o1 |= (_i0 & B04) >> 19; /*  5 */ \
+_o1 |= (_i0 & B27) <<  3; /* 28 */ \
+_o1 |= (_i0 & B19) >>  6; /* 20 */ \
+_o1 |= (_i0 & B11) >> 15; /* 12 */ \
+_o1 |= (_i0 & B03) >> 24; /*  4 */ \
+}
+
+/* 2x28b -> 8x6b */
+#define PC2_AUX(_i0, _i1, _o0, _o1) \
+{ \
+_o0 = _o1 = 0; \
+_o0 |= (_i0 & B13) << 11; /* 14 */ \
+_o0 |= (_i0 & B16) << 13; /* 17 */ \
+_o0 |= (_i0 & B10) <<  6; /* 11 */ \
+_o0 |= (_i0 & B23) << 18; /* 24 */ \
+_o0 |= (_i0 & B00) >>  6; /*  1 */ \
+_o0 |= (_i0 & B04) >>  3; /*  5 */ \
+_o0 |= (_i0 & B02) >>  8; /*  3 */ \
+_o0 |= (_i0 & B27) << 16; /* 28 */ \
+_o0 |= (_i0 & B14) <<  2; /* 15 */ \
+_o0 |= (_i0 & B05) >>  8; /*  6 */ \
+_o0 |= (_i0 & B20) <<  6; /* 21 */ \
+_o0 |= (_i0 & B09) >>  6; /* 10 */ \
+_o0 |= (_i0 & B22) <<  4; /* 23 */ \
+_o0 |= (_i0 & B18) >>  1; /* 19 */ \
+_o0 |= (_i0 & B11) >>  9; /* 12 */ \
+_o0 |= (_i0 & B03) >> 18; /*  4 */ \
+_o0 |= (_i0 & B25) <<  3; /* 26 */ \
+_o0 |= (_i0 & B07) >> 16; /*  8 */ \
+_o0 |= (_i0 & B15) >> 11; /* 16 */ \
+_o0 |= (_i0 & B06) >> 21; /*  7 */ \
+_o0 |= (_i0 & B26) >>  2; /* 27 */ \
+_o0 |= (_i0 & B19) >> 10; /* 20 */ \
+_o0 |= (_i0 & B12) >> 18; /* 13 */ \
+_o0 |= (_i0 & B01) >> 30; /*  2 */ \
+_o1 |= (_i1 & B12) << 10; /* 41 */ \
+_o1 |= (_i1 & B23) << 20; /* 52 */ \
+_o1 |= (_i1 & B02) >>  2; /* 31 */ \
+_o1 |= (_i1 & B08) <<  3; /* 37 */ \
+_o1 |= (_i1 & B18) << 12; /* 47 */ \
+_o1 |= (_i1 & B26) << 19; /* 55 */ \
+_o1 |= (_i1 & B01) >>  9; /* 30 */ \
+_o1 |= (_i1 & B11)      ; /* 40 */ \
+_o1 |= (_i1 & B22) << 10; /* 51 */ \
+_o1 |= (_i1 & B16) <<  3; /* 45 */ \
+_o1 |= (_i1 & B04) >> 10; /* 33 */ \
+_o1 |= (_i1 & B19) <<  4; /* 48 */ \
+_o1 |= (_i1 & B15) >>  3; /* 44 */ \
+_o1 |= (_i1 & B20) <<  1; /* 49 */ \
+_o1 |= (_i1 & B10) >> 10; /* 39 */ \
+_o1 |= (_i1 & B27) <<  6; /* 56 */ \
+_o1 |= (_i1 & B05) >> 17; /* 34 */ \
+_o1 |= (_i1 & B24) <<  1; /* 53 */ \
+_o1 |= (_i1 & B17) >>  9; /* 46 */ \
+_o1 |= (_i1 & B13) >> 14; /* 42 */ \
+_o1 |= (_i1 & B21) >>  7; /* 50 */ \
+_o1 |= (_i1 & B07) >> 22; /* 36 */ \
+_o1 |= (_i1 & B00) >> 30; /* 29 */ \
+_o1 |= (_i1 & B03) >> 28; /* 32 */ \
+}
+
+static
+Word s_p0[64] =
+{ /* Combined S-Box1 and permutation P */
+0x00808200, 0x00000000, 0x00008000, 0x00808202,
+0x00808002, 0x00008202, 0x00000002, 0x00008000,
+0x00000200, 0x00808200, 0x00808202, 0x00000200,
+0x00800202, 0x00808002, 0x00800000, 0x00000002,
+0x00000202, 0x00800200, 0x00800200, 0x00008200,
+0x00008200, 0x00808000, 0x00808000, 0x00800202,
+0x00008002, 0x00800002, 0x00800002, 0x00008002,
+0x00000000, 0x00000202, 0x00008202, 0x00800000,
+0x00008000, 0x00808202, 0x00000002, 0x00808000,
+0x00808200, 0x00800000, 0x00800000, 0x00000200,
+0x00808002, 0x00008000, 0x00008200, 0x00800002,
+0x00000200, 0x00000002, 0x00800202, 0x00008202,
+0x00808202, 0x00008002, 0x00808000, 0x00800202,
+0x00800002, 0x00000202, 0x00008202, 0x00808200,
+0x00000202, 0x00800200, 0x00800200, 0x00000000,
+0x00008002, 0x00008200, 0x00000000, 0x00808002
+};
+
+static
+Word s_p1[64] =
+{ /* Combined S-Box2 and permutation P */
+0x40084010, 0x40004000, 0x00004000, 0x00084010,
+0x00080000, 0x00000010, 0x40080010, 0x40004010,
+0x40000010, 0x40084010, 0x40084000, 0x40000000,
+0x40004000, 0x00080000, 0x00000010, 0x40080010,
+0x00084000, 0x00080010, 0x40004010, 0x00000000,
+0x40000000, 0x00004000, 0x00084010, 0x40080000,
+0x00080010, 0x40000010, 0x00000000, 0x00084000,
+0x00004010, 0x40084000, 0x40080000, 0x00004010,
+0x00000000, 0x00084010, 0x40080010, 0x00080000,
+0x40004010, 0x40080000, 0x40084000, 0x00004000,
+0x40080000, 0x40004000, 0x00000010, 0x40084010,
+0x00084010, 0x00000010, 0x00004000, 0x40000000,
+0x00004010, 0x40084000, 0x00080000, 0x40000010,
+0x00080010, 0x40004010, 0x40000010, 0x00080010,
+0x00084000, 0x00000000, 0x40004000, 0x00004010,
+0x40000000, 0x40080010, 0x40084010, 0x00084000
+};
+
+static
+Word s_p2[64] =
+{ /* Combined S-Box3 and permutation P */
+0x00000104, 0x04010100, 0x00000000, 0x04010004,
+0x04000100, 0x00000000, 0x00010104, 0x04000100,
+0x00010004, 0x04000004, 0x04000004, 0x00010000,
+0x04010104, 0x00010004, 0x04010000, 0x00000104,
+0x04000000, 0x00000004, 0x04010100, 0x00000100,
+0x00010100, 0x04010000, 0x04010004, 0x00010104,
+0x04000104, 0x00010100, 0x00010000, 0x04000104,
+0x00000004, 0x04010104, 0x00000100, 0x04000000,
+0x04010100, 0x04000000, 0x00010004, 0x00000104,
+0x00010000, 0x04010100, 0x04000100, 0x00000000,
+0x00000100, 0x00010004, 0x04010104, 0x04000100,
+0x04000004, 0x00000100, 0x00000000, 0x04010004,
+0x04000104, 0x00010000, 0x04000000, 0x04010104,
+0x00000004, 0x00010104, 0x00010100, 0x04000004,
+0x04010000, 0x04000104, 0x00000104, 0x04010000,
+0x00010104, 0x00000004, 0x04010004, 0x00010100
+};
+
+static
+Word s_p3[64] =
+{ /* Combined S-Box4 and permutation P */
+0x80401000, 0x80001040, 0x80001040, 0x00000040,
+0x00401040, 0x80400040, 0x80400000, 0x80001000,
+0x00000000, 0x00401000, 0x00401000, 0x80401040,
+0x80000040, 0x00000000, 0x00400040, 0x80400000,
+0x80000000, 0x00001000, 0x00400000, 0x80401000,
+0x00000040, 0x00400000, 0x80001000, 0x00001040,
+0x80400040, 0x80000000, 0x00001040, 0x00400040,
+0x00001000, 0x00401040, 0x80401040, 0x80000040,
+0x00400040, 0x80400000, 0x00401000, 0x80401040,
+0x80000040, 0x00000000, 0x00000000, 0x00401000,
+0x00001040, 0x00400040, 0x80400040, 0x80000000,
+0x80401000, 0x80001040, 0x80001040, 0x00000040,
+0x80401040, 0x80000040, 0x80000000, 0x00001000,
+0x80400000, 0x80001000, 0x00401040, 0x80400040,
+0x80001000, 0x00001040, 0x00400000, 0x80401000,
+0x00000040, 0x00400000, 0x00001000, 0x00401040
+};
+
+static
+Word s_p4[64] =
+{ /* Combined S-Box5 and permutation P */
+0x00000080, 0x01040080, 0x01040000, 0x21000080,
+0x00040000, 0x00000080, 0x20000000, 0x01040000,
+0x20040080, 0x00040000, 0x01000080, 0x20040080,
+0x21000080, 0x21040000, 0x00040080, 0x20000000,
+0x01000000, 0x20040000, 0x20040000, 0x00000000,
+0x20000080, 0x21040080, 0x21040080, 0x01000080,
+0x21040000, 0x20000080, 0x00000000, 0x21000000,
+0x01040080, 0x01000000, 0x21000000, 0x00040080,
+0x00040000, 0x21000080, 0x00000080, 0x01000000,
+0x20000000, 0x01040000, 0x21000080, 0x20040080,
+0x01000080, 0x20000000, 0x21040000, 0x01040080,
+0x20040080, 0x00000080, 0x01000000, 0x21040000,
+0x21040080, 0x00040080, 0x21000000, 0x21040080,
+0x01040000, 0x00000000, 0x20040000, 0x21000000,
+0x00040080, 0x01000080, 0x20000080, 0x00040000,
+0x00000000, 0x20040000, 0x01040080, 0x20000080
+};
+
+static
+Word s_p5[64] =
+{ /* Combined S-Box6 and permutation P */
+0x10000008, 0x10200000, 0x00002000, 0x10202008,
+0x10200000, 0x00000008, 0x10202008, 0x00200000,
+0x10002000, 0x00202008, 0x00200000, 0x10000008,
+0x00200008, 0x10002000, 0x10000000, 0x00002008,
+0x00000000, 0x00200008, 0x10002008, 0x00002000,
+0x00202000, 0x10002008, 0x00000008, 0x10200008,
+0x10200008, 0x00000000, 0x00202008, 0x10202000,
+0x00002008, 0x00202000, 0x10202000, 0x10000000,
+0x10002000, 0x00000008, 0x10200008, 0x00202000,
+0x10202008, 0x00200000, 0x00002008, 0x10000008,
+0x00200000, 0x10002000, 0x10000000, 0x00002008,
+0x10000008, 0x10202008, 0x00202000, 0x10200000,
+0x00202008, 0x10202000, 0x00000000, 0x10200008,
+0x00000008, 0x00002000, 0x10200000, 0x00202008,
+0x00002000, 0x00200008, 0x10002008, 0x00000000,
+0x10202000, 0x10000000, 0x00200008, 0x10002008
+};
+
+static
+Word s_p6[64] =
+{ /* Combined S-Box7 and permutation P */
+0x00100000, 0x02100001, 0x02000401, 0x00000000,
+0x00000400, 0x02000401, 0x00100401, 0x02100400,
+0x02100401, 0x00100000, 0x00000000, 0x02000001,
+0x00000001, 0x02000000, 0x02100001, 0x00000401,
+0x02000400, 0x00100401, 0x00100001, 0x02000400,
+0x02000001, 0x02100000, 0x02100400, 0x00100001,
+0x02100000, 0x00000400, 0x00000401, 0x02100401,
+0x00100400, 0x00000001, 0x02000000, 0x00100400,
+0x02000000, 0x00100400, 0x00100000, 0x02000401,
+0x02000401, 0x02100001, 0x02100001, 0x00000001,
+0x00100001, 0x02000000, 0x02000400, 0x00100000,
+0x02100400, 0x00000401, 0x00100401, 0x02100400,
+0x00000401, 0x02000001, 0x02100401, 0x02100000,
+0x00100400, 0x00000000, 0x00000001, 0x02100401,
+0x00000000, 0x00100401, 0x02100000, 0x00000400,
+0x02000001, 0x02000400, 0x00000400, 0x00100001
+};
+
+static
+Word s_p7[64] =
+{ /* Combined S-Box8 and permutation P */
+0x08000820, 0x00000800, 0x00020000, 0x08020820,
+0x08000000, 0x08000820, 0x00000020, 0x08000000,
+0x00020020, 0x08020000, 0x08020820, 0x00020800,
+0x08020800, 0x00020820, 0x00000800, 0x00000020,
+0x08020000, 0x08000020, 0x08000800, 0x00000820,
+0x00020800, 0x00020020, 0x08020020, 0x08020800,
+0x00000820, 0x00000000, 0x00000000, 0x08020020,
+0x08000020, 0x08000800, 0x00020820, 0x00020000,
+0x00020820, 0x00020000, 0x08020800, 0x00000800,
+0x00000020, 0x08020020, 0x00000800, 0x00020820,
+0x08000800, 0x00000020, 0x08000020, 0x08020000,
+0x08020020, 0x08000000, 0x00020000, 0x08000820,
+0x00000000, 0x08020820, 0x00020020, 0x08000020,
+0x08020000, 0x08000800, 0x08000820, 0x00000000,
+0x08020820, 0x00020800, 0x00020800, 0x00000820,
+0x00000820, 0x00020020, 0x08000000, 0x08020800
+};
+
+#define INITIAL_PERMUTATION(t, regL, regR) \
+        INITIAL_PERMUTATION_AUX(t[0], t[1], regL, regR)
+
+#define FINAL_PERMUTATION(regR, regL, t) \
+        FINAL_PERMUTATION_AUX(regR, regL, t[0], t[1])
+
+#define PC1(k, regC, regD) \
+        PC1_AUX(k[0], k[1], regC, regD)
+
+#define PC2(regC, regD, k) \
+        PC2_AUX(regC, regD, k[0], k[1])
+
+unsigned char G_padChar = (char) 0; /* Default pad charcater */
+
+static Word ROTATE_LEFT(Word x) 
+{
+	Word	a;
+	a = (x & 0x80000000) >> 27;
+	return (x << 1) | a;
+}
+
+static Word ROTATE_RIGHT(Word x) 
+{
+	Word	a;
+	a = x & 0x00000010;
+	return (x >> 1) | (a << 27);
+}
+
+/*
+** The S Box transformations and the permutation P are combined in the vectors
+** s_p0 - s_p7. Permutation E and the MOD 2 addition with the intermediate key
+** are then done "inline" on each round. The intermediate key is already in a
+** a 8x6bit form because of the modified permuation PC2 used.
+*/
+
+#if !defined(WORDS_BIGENDIAN)
+
+#define DES(t, ik) \
+{ \
+    register Word l, r, reg32, round; \
+    register unsigned char *bb; \
+    INITIAL_PERMUTATION(t, l, r); \
+    for(bb = (unsigned char *) ik, round = 0x8000; round; bb += 8, round >>= 1) { \
+        register Word w = (r << 1) | (r >> 31); \
+        reg32  = s_p7[( w        & 0x3f) ^ bb[4]]; \
+        reg32 |= s_p6[((w >>= 4) & 0x3f) ^ bb[5]]; \
+        reg32 |= s_p5[((w >>= 4) & 0x3f) ^ bb[6]]; \
+        reg32 |= s_p4[((w >>= 4) & 0x3f) ^ bb[7]]; \
+        reg32 |= s_p3[((w >>= 4) & 0x3f) ^ bb[0]]; \
+        reg32 |= s_p2[((w >>= 4) & 0x3f) ^ bb[1]]; \
+        reg32 |= s_p1[((w >>  4) & 0x3f) ^ bb[2]]; \
+        reg32 |= s_p0[(((r & 0x1) << 5) | ((r & 0xf8000000) >> 27)) ^ bb[3]]; \
+        reg32 ^= l; \
+        l = r; \
+        r = reg32; \
+    } \
+    FINAL_PERMUTATION(r, l, t); \
+}
+
+
+#define MAKE_LITTLE_ENDIAN(t, s) \
+{ \
+    register unsigned int z, l = s/4; \
+    register Word *tp = (Word *) t; \
+    for(z = 0; z < l; ++z) tp[z] = htonl(tp[z]); \
+}
+
+#else /* WORDS_BIGENDIAN */
+
+#define DES(t, ik) \
+{ \
+    register Word l, r, reg32, round; \
+    register unsigned char *bb; \
+    INITIAL_PERMUTATION(t, l, r); \
+    for(bb = (unsigned char *) ik, round = 0x8000; round; bb += 8, round >>= 1) { \
+        register Word w = (r << 1) | (r >> 31); \
+        reg32  = s_p7[( w        & 0x3f) ^ bb[7]]; \
+        reg32 |= s_p6[((w >>= 4) & 0x3f) ^ bb[6]]; \
+        reg32 |= s_p5[((w >>= 4) & 0x3f) ^ bb[5]]; \
+        reg32 |= s_p4[((w >>= 4) & 0x3f) ^ bb[4]]; \
+        reg32 |= s_p3[((w >>= 4) & 0x3f) ^ bb[3]]; \
+        reg32 |= s_p2[((w >>= 4) & 0x3f) ^ bb[2]]; \
+        reg32 |= s_p1[((w >>  4) & 0x3f) ^ bb[1]]; \
+        reg32 |= s_p0[(((r & 0x1) << 5) | ((r & 0xf8000000) >> 27)) ^ bb[0]]; \
+        reg32 ^= l; \
+        l = r; \
+        r = reg32; \
+    } \
+    FINAL_PERMUTATION(r, l, t); \
+}
+
+#endif /* WORDS_BIGENDIAN */
+
+int
+qfDES(unsigned char	*key,
+      unsigned char	*data,
+      unsigned int 	 size,
+const QFDES_what   	 what,
+const QFDES_mode   	 mode,
+      unsigned char	*initVec)
+{
+    /* Store some info to optimise for multiple calls ... */
+    static unsigned char desKey[8], desKeys[128];
+    static Word 	*oldKey = (Word *) desKey,
+         		*keys   = (Word *) desKeys;
+    static QFDES_what 	oldWhat;
+    static QFDES_mode 	oldMode;
+    unsigned char 	b0[8], b1[8]; /* feedback blocks */
+    Word 		*newKey = (Word *) key, /* key from user */
+         		*text,                  /* text to be [en|de]crypted */
+         		*cb     = (Word *) b0,  /* the chained block in CBC mode */
+         		*cb1    = (Word *) b1;  /* a copy for use when decrypting */
+
+#if !defined(WORDS_BIGENDIAN)
+    unsigned int origSize = size;
+    MAKE_LITTLE_ENDIAN(key, 8);
+    MAKE_LITTLE_ENDIAN(data, origSize);
+#endif
+
+    /*
+    ** Check new key against old key
+    ** and set up intermediate keys.
+    */
+    if (newKey[0] != oldKey[0] || newKey[1] != oldKey[1]) {
+        Word c, d;  /* C and D registers */
+
+        oldKey[0] = newKey[0]; oldKey[1] = newKey[1];
+        oldWhat   = what;
+        oldMode   = mode;
+
+        PC1(newKey, c, d);
+
+        if ((what == qfDES_encrypt) || (mode == qfDES_cfb) || (mode == qfDES_ofb)) {
+		int 	 z;
+		Word	 r; 
+		Word	*k = keys; 
+		Word 	 rol[16] = {1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1};
+
+		for(z = 0; z < 16; z++, k += 2) { 
+			for (r = 0; r < rol[z]; r++) {
+				c = ROTATE_LEFT(c); 
+				d = ROTATE_LEFT(d);
+			}
+			PC2(c, d, k); 
+		}
+        } else {
+		int 	 z;
+		Word	 r; 
+		Word	*k = keys; 
+		Word 	 ror[16] = {0, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1};
+
+		for(z = 0; z < 16; z++, k += 2) { 
+			r = 0;
+			while (ror[z] > r) {
+				r++;
+				c = ROTATE_RIGHT(c); 
+				d = ROTATE_RIGHT(d);
+			}
+			PC2(c, d, k); 
+		} 
+	}
+    } else if ((what != oldWhat) && ((mode == qfDES_ecb) || (mode == qfDES_cbc))) {
+        /*
+        ** Same key but different direction.
+        ** Reverse intermediate key sequence (ECB and CBC).
+        */
+        Word *ik1, *ik2, ik3[2];
+
+        for(ik1 = keys, ik2 = &(keys[30]); ik1 < ik2; ik1 += 2, ik2 -= 2) {
+            ik3[0] = ik1[0]; ik3[1] = ik1[1];
+            ik1[0] = ik2[0]; ik1[1] = ik2[1];
+            ik2[0] = ik3[0]; ik2[1] = ik3[1];
+        }
+
+        oldWhat = what;
+    }
+
+    /* Set up initilaisation vector */
+    if (mode != qfDES_ecb) {
+        if (initVec) {
+            { cb[0] = ((Word *) initVec)[0]; cb[1] = ((Word *) initVec)[1]; }
+        } else {
+            cb[0] = 0;
+	    cb[1] = 0;
+	}
+#if !defined(WORDS_BIGENDIAN)
+        MAKE_LITTLE_ENDIAN(cb, 8);
+#endif
+    }
+
+    /*
+    ** Lots of gotos and code duplication follow (arrgh) but it speeds
+    ** it up a wee bit!
+    ** What would be more useful is looking more carefully at the DES
+    ** permutations to produce more efficient versions of the macros
+    ** of the "auto-generated" versions used in qfDES-aux.c.
+    */
+
+    size >>= 3; /* this is always a multpile of 8 */
+
+    if (what == qfDES_encrypt) {
+        switch ((int) mode) {
+        case ((int) qfDES_ecb): goto _ECB_;
+        case ((int) qfDES_cbc): goto _CBC_encrypt_;
+        case ((int) qfDES_cfb): goto _CFB_encrypt_;
+        case ((int) qfDES_ofb): goto _OFB_;
+        }
+    }
+    else {
+        switch ((int) mode) {
+        case ((int) qfDES_ecb): goto _ECB_;
+        case ((int) qfDES_cbc): goto _CBC_decrypt_;
+        case ((int) qfDES_cfb): goto _CFB_decrypt_;
+        case ((int) qfDES_ofb): goto _OFB_;
+        }
+    }
+
+_ECB_:
+
+    /* ECB */
+    for(text = (Word *) data; size; --size, text += 2)
+        { DES(text, keys); }
+
+    goto _exit_qfDES_;
+
+_CBC_encrypt_:
+
+    /* CBC Encryption */
+    for(text = (Word *) data; size; --size, text += 2) {
+
+        /* chaining block */
+        text[0] ^= cb[0]; text[1] ^= cb[1];
+
+        DES(text, keys);
+
+        /* set up chaining block for next round */
+        cb[0] = text[0]; cb[1] = text[1];
+    }
+
+    goto _initVec_;
+
+_CBC_decrypt_:
+
+    /* CBC Decryption */
+    for(text = (Word *) data; size; --size, text += 2) {
+
+        /* set up chaining block */
+        /*
+        ** The decryption is done in place so I need
+        ** to copy this text block for the next round.
+        */
+        cb1[0] = text[0]; cb1[1] = text[1];
+
+        DES(text, keys);
+
+        /* chaining block for next round */
+        text[0] ^= cb[0]; text[1] ^= cb[1];
+
+        /*
+        ** Copy back the saved encrypted text - this makes
+        ** CBC decryption slower than CBC encryption.
+        */
+        cb[0] = cb1[0]; cb[1] = cb1[1];
+    }
+
+    goto _initVec_;
+
+_CFB_encrypt_:
+
+    /* CFB Encryption */
+    for(text = (Word *) data; size; --size, text += 2) {
+
+        /* use cb as the feedback block */
+        DES(cb, keys);
+
+        text[0] ^= cb[0]; text[1] ^= cb[1];
+
+        /* set up feedback block for next round */
+        cb[0] = text[0]; cb[1] = text[1];
+    }
+
+    goto _initVec_;
+
+_CFB_decrypt_:
+
+    /* CFB Decryption */
+    for(text = (Word *) data; size; --size, text += 2) {
+
+        /* set up feedback block */
+        /*
+        ** The decryption is done in place so I need
+        ** to copy this text block for the next round.
+        */
+        cb1[0] = text[0]; cb1[1] = text[1];
+
+        /* use cb as the feedback block */
+        DES(cb, keys);
+
+        text[0] ^= cb[0]; text[1] ^= cb[1];
+
+        /* set up feedback block for next round */
+        cb[0] = cb1[0]; cb[1] = cb1[1];
+    }
+
+    goto _initVec_;
+
+_OFB_:
+
+    /* OFB */
+    for(text = (Word *) data; size; --size, text += 2) {
+
+        /* use cb as the feed back block */
+        DES(cb, keys);
+
+        text[0] ^= cb[0]; text[1] ^= cb[1];
+    }
+
+_initVec_:
+
+    /*
+    ** Copy the final chained block back to initVec (CBC, CFB and OFB).
+    ** This allows the [en|de]cryption of large amounts of data in small
+    ** chunks.
+    */
+    if (initVec) {
+        ((Word *) initVec)[0] = cb[0];
+        ((Word *) initVec)[1] = cb[1];
+
+#if !defined(WORDS_BIGENDIAN)
+        MAKE_LITTLE_ENDIAN(initVec, 8);
+#endif
+    }
+
+_exit_qfDES_:
+
+#if !defined(WORDS_BIGENDIAN)
+    MAKE_LITTLE_ENDIAN(key, 8);
+    MAKE_LITTLE_ENDIAN(data, origSize);
+#endif
+
+    return 0;
+}
+
+/*
+** This function sets bit 8 of each byte to odd or even parity as requested.
+** It is assumed that the right-most bit of each byte is the parity bit.
+** Although this is really only used by the two key generation functions below,
+** it may be useful to someone.
+*/
+
+void qfDES_setParity(unsigned char *ptr, unsigned int size, const QFDES_parity parity)
+{
+    unsigned int i, mask, bits;
+
+    for(i = 0; i < size; ++i, ++ptr) {
+        for(mask = 0x80, bits = 0; mask > 0x01; mask >>= 1)
+            if (((unsigned int) *ptr) & mask) ++bits;
+
+        *ptr |= bits % 2 == (unsigned int) parity ? 0x00 : 0x01;
+    }
+}
+
+unsigned int qfDES_checkParity(unsigned char *ptr, unsigned int size, const QFDES_parity parity)
+{
+    unsigned int i, mask, bits, parityBit, parityErrors = 0;
+
+    for(i = 0; i < size; ++i, ++ptr) {
+        for(mask = 0x80, bits = 0; mask > 0x01; mask >>= 1)
+            if (((unsigned int) *ptr) & mask) ++bits;
+
+        parityBit = bits % 2 == (unsigned int) parity ? 0 : 1;
+
+        if ((((unsigned int) *ptr) & 0x1) != parityBit)
+            ++parityErrors;
+    }
+
+    return parityErrors;
+}
+
+static
+unsigned char weakKeys[18][8] =
+{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11},
+ {0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01},
+ {0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe},
+ {0x1f, 0x1f, 0x1f, 0x1f, 0x0e, 0x0e, 0x0e, 0x0e},
+ {0xe0, 0xe0, 0xe0, 0xe0, 0xf1, 0xf1, 0xf1, 0xf1},
+ {0x01, 0xfe, 0x01, 0xfe, 0x01, 0xfe, 0x01, 0xfe},
+ {0xfe, 0x01, 0xfe, 0x01, 0xfe, 0x01, 0xfe, 0x01},
+ {0x1f, 0xe0, 0x1f, 0xe0, 0x0e, 0xf1, 0x0e, 0xf1},
+ {0xe0, 0x1f, 0xe0, 0x1f, 0xf1, 0x0e, 0xf1, 0x0e},
+ {0x01, 0xe0, 0x01, 0xe0, 0x01, 0xf1, 0x01, 0xf1},
+ {0xe0, 0x01, 0xe0, 0x01, 0xf1, 0x01, 0xf1, 0x01},
+ {0x1f, 0xfe, 0x1f, 0xfe, 0x0e, 0xfe, 0x0e, 0xfe},
+ {0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x0e, 0xfe, 0x0e},
+ {0x01, 0x1f, 0x01, 0x1f, 0x01, 0x0e, 0x01, 0x0e},
+ {0x1f, 0x01, 0x1f, 0x01, 0x0e, 0x01, 0x0e, 0x01},
+ {0xe0, 0xfe, 0xe0, 0xfe, 0xf1, 0xfe, 0xf1, 0xfe},
+ {0xfe, 0xe0, 0xfe, 0xe0, 0xfe, 0xf1, 0xfe, 0xf1}};
+
+/*
+** Although this is really only used by the key generation function below,
+** it may be handy to someone.
+*/
+
+int qfDES_checkWeakKeys(unsigned char *key)
+{
+    unsigned char *bp;
+    int i;
+
+    for(bp = weakKeys[i = 0]; i < 18; bp = weakKeys[++i])
+        if (memcmp((void *) key, (void *) bp, 8) == 0) return -1;
+
+    return 0;
+}
+
+/*
+** The following function attempts to genreate a random key or IV.
+** It relies on the randomness of the  of the random(3) function. Although
+** it is probably not particularly fast, keys and IV will most probably be
+** generated off-line so it does not matter too much.
+*/
+
+unsigned char *qfDES_generate(const QFDES_generate what)
+{
+    static
+    unsigned char buffer[8];
+    static
+    int flag = 0;
+
+    unsigned char *bp;
+    long mask = what == qfDES_key ? 0xfe : 0xff;
+
+    /* Set up a seed - 42 is the answer ... */
+    if (!flag) {
+        lbl_srandom((int) (getpid() * 42) ^ (int) time((time_t *) 0));
+        flag = 1;
+    }
+    do {
+
+        for(bp = buffer; bp <= &(buffer[7]); *bp++ = (unsigned char) (lbl_random() & mask));
+
+        if (what ==  qfDES_key)
+            qfDES_setParity(buffer, 8, qfDES_odd);
+
+    } while(what == qfDES_key ? qfDES_checkWeakKeys(buffer) : 0);
+
+    return buffer;
+}
+
+unsigned char
+qfDES_setPad(unsigned char pad)
+{ 
+    unsigned char b = G_padChar; G_padChar = pad; return b; 
+}
+

Added: experimental/j/Elphel333/rtp/daemon/rtp/qfDES.h
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/qfDES.h	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/qfDES.h	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,70 @@
+/*****************************************************************************
+
+
+
+
+Saleem N. Bhatti
+February 1993
+*****************************************************************************/
+
+#if !defined(_qfDES_h_)
+#define      _qfDES_h_
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/* what */
+typedef enum {qfDES_encrypt, qfDES_decrypt} QFDES_what;
+
+/* mode */
+typedef enum {qfDES_ecb, qfDES_cbc, qfDES_cfb, qfDES_ofb} QFDES_mode;
+
+/* parity */
+typedef enum {qfDES_even, qfDES_odd} QFDES_parity;
+
+/* key/IV generation */
+typedef enum {qfDES_key, qfDES_iv} QFDES_generate;
+
+
+/* This does it all */
+int qfDES (unsigned char *key, unsigned char *data, unsigned int size, const QFDES_what what, const QFDES_mode mode, unsigned char *initVec);
+
+/* Handy macros */
+#define qfDES_ECB_e(_key, _data, _size) qfDES(_key, _data, _size, qfDES_encrypt, qfDES_ecb, (unsigned char *) 0)
+#define qfDES_ECB_d(_key, _data, _size) qfDES(_key, _data, _size, qfDES_decrypt, qfDES_ecb, (unsigned char *) 0)
+
+#define qfDES_CBC_e(_key, _data, _size, _initVec) qfDES(_key, _data, _size, qfDES_encrypt, qfDES_cbc, _initVec)
+#define qfDES_CBC_d(_key, _data, _size, _initVec) qfDES(_key, _data, _size, qfDES_decrypt, qfDES_cbc, _initVec)
+
+#define qfDES_CFB_e(_key, _data, _size, _initVec) qfDES(_key, _data, _size, qfDES_encrypt, qfDES_cfb, _initVec)
+#define qfDES_CFB_d(_key, _data, _size, _initVec) qfDES(_key, _data, _size, qfDES_decrypt, qfDES_cfb, _initVec)
+
+#define qfDES_OFB_e(_key, _data, _size, _initVec) qfDES(_key, _data, _size, qfDES_encrypt, qfDES_ofb, _initVec)
+#define qfDES_OFB_d(_key, _data, _size, _initVec) qfDES(_key, _data, _size, qfDES_decrypt, qfDES_ofb, _initVec)
+
+/* Padded [m|re]alloc() */
+unsigned char    qfDES_setPad (unsigned char pad);
+
+#define qfDES_padSpace() qfDES_setPad((unsigned char) ' ')
+#define qfDES_padZero() qfDES_setPad((unsigned char) '\0')
+
+/* The size of text in a qfDES_malloc()ed block */
+#define qfDES_plainTextSize(_ptr, _size) (unsigned int) ((_size) - (unsigned int) (_ptr)[(_size) - 1])
+
+/* Keys */
+void qfDES_setParity (unsigned char *ptr, unsigned int size, const QFDES_parity parity);
+unsigned int qfDES_checkParity (unsigned char *ptr, unsigned int size, const QFDES_parity parity);
+
+unsigned char *qfDES_generate (const QFDES_generate what); /* returns a pointer to static memory */
+
+#define qfDES_generateKey() qfDES_generate(qfDES_key)
+#define qfDES_generateIV() qfDES_generate(qfDES_iv)
+
+int qfDES_checkWeakKeys (unsigned char *key);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* !_qfDES_h_ */

Added: experimental/j/Elphel333/rtp/daemon/rtp/rijndael-alg-fst.c
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/rijndael-alg-fst.c	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/rijndael-alg-fst.c	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,441 @@
+/*
+ * rijndael-alg-fst.c   v2.4   April '2000
+ *
+ * Optimised ANSI C code
+ *
+ * authors: v1.0: Antoon Bosselaers
+ *          v2.0: Vincent Rijmen
+ *          v2.3: Paulo Barreto
+ *          v2.4: Vincent Rijmen
+ *
+ * This code is placed in the public domain.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "rijndael-alg-fst.h"
+
+#include "boxes-fst.dat"
+
+int rijndaelKeySched(word8 k[MAXKC][4], word8 W[MAXROUNDS+1][4][4], int ROUNDS) {
+	/* Calculate the necessary round keys
+	 * The number of calculations depends on keyBits and blockBits
+	 */ 
+	int j, r, t, rconpointer = 0;
+	word8 tk[MAXKC][4];
+	int KC = ROUNDS - 6;
+
+	for (j = KC-1; j >= 0; j--) {
+		*((word32*)tk[j]) = *((word32*)k[j]);
+	}
+	r = 0;
+	t = 0;
+	/* copy values into round key array */
+	for (j = 0; (j < KC) && (r < ROUNDS + 1); ) {
+		for (; (j < KC) && (t < 4); j++, t++) {
+			*((word32*)W[r][t]) = *((word32*)tk[j]);
+		}
+		if (t == 4) {
+			r++;
+			t = 0;
+		}
+	}
+		
+	while (r < ROUNDS + 1) { /* while not enough round key material calculated */
+		/* calculate new values */
+		tk[0][0] ^= S[tk[KC-1][1]];
+		tk[0][1] ^= S[tk[KC-1][2]];
+		tk[0][2] ^= S[tk[KC-1][3]];
+		tk[0][3] ^= S[tk[KC-1][0]];
+		tk[0][0] ^= rcon[rconpointer++];
+
+		if (KC != 8) {
+			for (j = 1; j < KC; j++) {
+				*((word32*)tk[j]) ^= *((word32*)tk[j-1]);
+			}
+		} else {
+			for (j = 1; j < KC/2; j++) {
+				*((word32*)tk[j]) ^= *((word32*)tk[j-1]);
+			}
+			tk[KC/2][0] ^= S[tk[KC/2 - 1][0]];
+			tk[KC/2][1] ^= S[tk[KC/2 - 1][1]];
+			tk[KC/2][2] ^= S[tk[KC/2 - 1][2]];
+			tk[KC/2][3] ^= S[tk[KC/2 - 1][3]];
+			for (j = KC/2 + 1; j < KC; j++) {
+				*((word32*)tk[j]) ^= *((word32*)tk[j-1]);
+			}
+		}
+		/* copy values into round key array */
+		for (j = 0; (j < KC) && (r < ROUNDS + 1); ) {
+			for (; (j < KC) && (t < 4); j++, t++) {
+				*((word32*)W[r][t]) = *((word32*)tk[j]);
+			}
+			if (t == 4) {
+				r++;
+				t = 0;
+			}
+		}
+	}		
+	return 0;
+}
+
+int rijndaelKeyEncToDec(word8 W[MAXROUNDS+1][4][4], int ROUNDS) {
+	int r;
+	word8 *w;
+
+	for (r = 1; r < ROUNDS; r++) {
+		w = W[r][0];
+		*((word32*)w) =
+			  *((word32*)U1[w[0]])
+			^ *((word32*)U2[w[1]])
+			^ *((word32*)U3[w[2]])
+			^ *((word32*)U4[w[3]]);
+
+		w = W[r][1];
+		*((word32*)w) =
+			  *((word32*)U1[w[0]])
+			^ *((word32*)U2[w[1]])
+			^ *((word32*)U3[w[2]])
+			^ *((word32*)U4[w[3]]);
+
+		w = W[r][2];
+		*((word32*)w) =
+			  *((word32*)U1[w[0]])
+			^ *((word32*)U2[w[1]])
+			^ *((word32*)U3[w[2]])
+			^ *((word32*)U4[w[3]]);
+
+		w = W[r][3];
+		*((word32*)w) =
+			  *((word32*)U1[w[0]])
+			^ *((word32*)U2[w[1]])
+			^ *((word32*)U3[w[2]])
+			^ *((word32*)U4[w[3]]);
+	}
+	return 0;
+}	
+
+/**
+ * Encrypt a single block. 
+ */
+int rijndaelEncrypt(word8 a[16], word8 b[16], word8 rk[MAXROUNDS+1][4][4], int ROUNDS) {
+	int r;
+	word8 temp[4][4];
+
+    *((word32*)temp[0]) = *((word32*)(a   )) ^ *((word32*)rk[0][0]);
+    *((word32*)temp[1]) = *((word32*)(a+ 4)) ^ *((word32*)rk[0][1]);
+    *((word32*)temp[2]) = *((word32*)(a+ 8)) ^ *((word32*)rk[0][2]);
+    *((word32*)temp[3]) = *((word32*)(a+12)) ^ *((word32*)rk[0][3]);
+    *((word32*)(b    )) = *((word32*)T1[temp[0][0]])
+						^ *((word32*)T2[temp[1][1]])
+						^ *((word32*)T3[temp[2][2]]) 
+						^ *((word32*)T4[temp[3][3]]);
+    *((word32*)(b + 4)) = *((word32*)T1[temp[1][0]])
+						^ *((word32*)T2[temp[2][1]])
+						^ *((word32*)T3[temp[3][2]]) 
+						^ *((word32*)T4[temp[0][3]]);
+    *((word32*)(b + 8)) = *((word32*)T1[temp[2][0]])
+						^ *((word32*)T2[temp[3][1]])
+						^ *((word32*)T3[temp[0][2]]) 
+						^ *((word32*)T4[temp[1][3]]);
+    *((word32*)(b +12)) = *((word32*)T1[temp[3][0]])
+						^ *((word32*)T2[temp[0][1]])
+						^ *((word32*)T3[temp[1][2]]) 
+						^ *((word32*)T4[temp[2][3]]);
+	for (r = 1; r < ROUNDS-1; r++) {
+		*((word32*)temp[0]) = *((word32*)(b   )) ^ *((word32*)rk[r][0]);
+		*((word32*)temp[1]) = *((word32*)(b+ 4)) ^ *((word32*)rk[r][1]);
+		*((word32*)temp[2]) = *((word32*)(b+ 8)) ^ *((word32*)rk[r][2]);
+		*((word32*)temp[3]) = *((word32*)(b+12)) ^ *((word32*)rk[r][3]);
+
+		*((word32*)(b    )) = *((word32*)T1[temp[0][0]])
+							^ *((word32*)T2[temp[1][1]])
+							^ *((word32*)T3[temp[2][2]]) 
+							^ *((word32*)T4[temp[3][3]]);
+		*((word32*)(b + 4)) = *((word32*)T1[temp[1][0]])
+							^ *((word32*)T2[temp[2][1]])
+							^ *((word32*)T3[temp[3][2]]) 
+							^ *((word32*)T4[temp[0][3]]);
+		*((word32*)(b + 8)) = *((word32*)T1[temp[2][0]])
+							^ *((word32*)T2[temp[3][1]])
+							^ *((word32*)T3[temp[0][2]]) 
+							^ *((word32*)T4[temp[1][3]]);
+		*((word32*)(b +12)) = *((word32*)T1[temp[3][0]])
+							^ *((word32*)T2[temp[0][1]])
+							^ *((word32*)T3[temp[1][2]]) 
+							^ *((word32*)T4[temp[2][3]]);
+	}
+	/* last round is special */   
+	*((word32*)temp[0]) = *((word32*)(b   )) ^ *((word32*)rk[ROUNDS-1][0]);
+	*((word32*)temp[1]) = *((word32*)(b+ 4)) ^ *((word32*)rk[ROUNDS-1][1]);
+	*((word32*)temp[2]) = *((word32*)(b+ 8)) ^ *((word32*)rk[ROUNDS-1][2]);
+	*((word32*)temp[3]) = *((word32*)(b+12)) ^ *((word32*)rk[ROUNDS-1][3]);
+	b[ 0] = T1[temp[0][0]][1];
+	b[ 1] = T1[temp[1][1]][1];
+	b[ 2] = T1[temp[2][2]][1];
+	b[ 3] = T1[temp[3][3]][1];
+	b[ 4] = T1[temp[1][0]][1];
+	b[ 5] = T1[temp[2][1]][1];
+	b[ 6] = T1[temp[3][2]][1];
+	b[ 7] = T1[temp[0][3]][1];
+	b[ 8] = T1[temp[2][0]][1];
+	b[ 9] = T1[temp[3][1]][1];
+	b[10] = T1[temp[0][2]][1];
+	b[11] = T1[temp[1][3]][1];
+	b[12] = T1[temp[3][0]][1];
+	b[13] = T1[temp[0][1]][1];
+	b[14] = T1[temp[1][2]][1];
+	b[15] = T1[temp[2][3]][1];
+	*((word32*)(b   )) ^= *((word32*)rk[ROUNDS][0]);
+	*((word32*)(b+ 4)) ^= *((word32*)rk[ROUNDS][1]);
+	*((word32*)(b+ 8)) ^= *((word32*)rk[ROUNDS][2]);
+	*((word32*)(b+12)) ^= *((word32*)rk[ROUNDS][3]);
+
+	return 0;
+}
+
+#ifdef INTERMEDIATE_VALUE_KAT
+/**
+ * Encrypt only a certain number of rounds.
+ * Only used in the Intermediate Value Known Answer Test.
+ */
+int rijndaelEncryptRound(word8 a[4][4], word8 rk[MAXROUNDS+1][4][4], int ROUNDS, int rounds) {
+	int r;
+	word8 temp[4][4];
+
+	/* make number of rounds sane */
+	if (rounds > ROUNDS) {
+		rounds = ROUNDS;
+	}
+
+	*((word32*)a[0]) = *((word32*)a[0]) ^ *((word32*)rk[0][0]);
+	*((word32*)a[1]) = *((word32*)a[1]) ^ *((word32*)rk[0][1]);
+	*((word32*)a[2]) = *((word32*)a[2]) ^ *((word32*)rk[0][2]);
+	*((word32*)a[3]) = *((word32*)a[3]) ^ *((word32*)rk[0][3]);
+
+	for (r = 1; (r <= rounds) && (r < ROUNDS); r++) {
+		*((word32*)temp[0]) = *((word32*)T1[a[0][0]])
+           ^ *((word32*)T2[a[1][1]])
+           ^ *((word32*)T3[a[2][2]]) 
+           ^ *((word32*)T4[a[3][3]]);
+		*((word32*)temp[1]) = *((word32*)T1[a[1][0]])
+           ^ *((word32*)T2[a[2][1]])
+           ^ *((word32*)T3[a[3][2]]) 
+           ^ *((word32*)T4[a[0][3]]);
+		*((word32*)temp[2]) = *((word32*)T1[a[2][0]])
+           ^ *((word32*)T2[a[3][1]])
+           ^ *((word32*)T3[a[0][2]]) 
+           ^ *((word32*)T4[a[1][3]]);
+		*((word32*)temp[3]) = *((word32*)T1[a[3][0]])
+           ^ *((word32*)T2[a[0][1]])
+           ^ *((word32*)T3[a[1][2]]) 
+           ^ *((word32*)T4[a[2][3]]);
+		*((word32*)a[0]) = *((word32*)temp[0]) ^ *((word32*)rk[r][0]);
+		*((word32*)a[1]) = *((word32*)temp[1]) ^ *((word32*)rk[r][1]);
+		*((word32*)a[2]) = *((word32*)temp[2]) ^ *((word32*)rk[r][2]);
+		*((word32*)a[3]) = *((word32*)temp[3]) ^ *((word32*)rk[r][3]);
+	}
+	if (rounds == ROUNDS) {
+	   	/* last round is special */   
+	   	temp[0][0] = T1[a[0][0]][1];
+	   	temp[0][1] = T1[a[1][1]][1];
+	   	temp[0][2] = T1[a[2][2]][1]; 
+	   	temp[0][3] = T1[a[3][3]][1];
+	   	temp[1][0] = T1[a[1][0]][1];
+	   	temp[1][1] = T1[a[2][1]][1];
+	   	temp[1][2] = T1[a[3][2]][1]; 
+	   	temp[1][3] = T1[a[0][3]][1];
+	   	temp[2][0] = T1[a[2][0]][1];
+	   	temp[2][1] = T1[a[3][1]][1];
+	   	temp[2][2] = T1[a[0][2]][1]; 
+	   	temp[2][3] = T1[a[1][3]][1];
+	   	temp[3][0] = T1[a[3][0]][1];
+	   	temp[3][1] = T1[a[0][1]][1];
+	   	temp[3][2] = T1[a[1][2]][1]; 
+	   	temp[3][3] = T1[a[2][3]][1];
+		*((word32*)a[0]) = *((word32*)temp[0]) ^ *((word32*)rk[ROUNDS][0]);
+		*((word32*)a[1]) = *((word32*)temp[1]) ^ *((word32*)rk[ROUNDS][1]);
+		*((word32*)a[2]) = *((word32*)temp[2]) ^ *((word32*)rk[ROUNDS][2]);
+		*((word32*)a[3]) = *((word32*)temp[3]) ^ *((word32*)rk[ROUNDS][3]);
+	}
+
+	return 0;
+}   
+#endif /* INTERMEDIATE_VALUE_KAT */
+
+/**
+ * Decrypt a single block.
+ */
+int rijndaelDecrypt(word8 a[16], word8 b[16], word8 rk[MAXROUNDS+1][4][4], int ROUNDS) {
+	int r;
+	word8 temp[4][4];
+	
+    *((word32*)temp[0]) = *((word32*)(a   )) ^ *((word32*)rk[ROUNDS][0]);
+    *((word32*)temp[1]) = *((word32*)(a+ 4)) ^ *((word32*)rk[ROUNDS][1]);
+    *((word32*)temp[2]) = *((word32*)(a+ 8)) ^ *((word32*)rk[ROUNDS][2]);
+    *((word32*)temp[3]) = *((word32*)(a+12)) ^ *((word32*)rk[ROUNDS][3]);
+
+    *((word32*)(b   )) = *((word32*)T5[temp[0][0]])
+           ^ *((word32*)T6[temp[3][1]])
+           ^ *((word32*)T7[temp[2][2]]) 
+           ^ *((word32*)T8[temp[1][3]]);
+	*((word32*)(b+ 4)) = *((word32*)T5[temp[1][0]])
+           ^ *((word32*)T6[temp[0][1]])
+           ^ *((word32*)T7[temp[3][2]]) 
+           ^ *((word32*)T8[temp[2][3]]);
+	*((word32*)(b+ 8)) = *((word32*)T5[temp[2][0]])
+           ^ *((word32*)T6[temp[1][1]])
+           ^ *((word32*)T7[temp[0][2]]) 
+           ^ *((word32*)T8[temp[3][3]]);
+	*((word32*)(b+12)) = *((word32*)T5[temp[3][0]])
+           ^ *((word32*)T6[temp[2][1]])
+           ^ *((word32*)T7[temp[1][2]]) 
+           ^ *((word32*)T8[temp[0][3]]);
+	for (r = ROUNDS-1; r > 1; r--) {
+		*((word32*)temp[0]) = *((word32*)(b   )) ^ *((word32*)rk[r][0]);
+		*((word32*)temp[1]) = *((word32*)(b+ 4)) ^ *((word32*)rk[r][1]);
+		*((word32*)temp[2]) = *((word32*)(b+ 8)) ^ *((word32*)rk[r][2]);
+		*((word32*)temp[3]) = *((word32*)(b+12)) ^ *((word32*)rk[r][3]);
+		*((word32*)(b   )) = *((word32*)T5[temp[0][0]])
+           ^ *((word32*)T6[temp[3][1]])
+           ^ *((word32*)T7[temp[2][2]]) 
+           ^ *((word32*)T8[temp[1][3]]);
+		*((word32*)(b+ 4)) = *((word32*)T5[temp[1][0]])
+           ^ *((word32*)T6[temp[0][1]])
+           ^ *((word32*)T7[temp[3][2]]) 
+           ^ *((word32*)T8[temp[2][3]]);
+		*((word32*)(b+ 8)) = *((word32*)T5[temp[2][0]])
+           ^ *((word32*)T6[temp[1][1]])
+           ^ *((word32*)T7[temp[0][2]]) 
+           ^ *((word32*)T8[temp[3][3]]);
+		*((word32*)(b+12)) = *((word32*)T5[temp[3][0]])
+           ^ *((word32*)T6[temp[2][1]])
+           ^ *((word32*)T7[temp[1][2]]) 
+           ^ *((word32*)T8[temp[0][3]]);
+	}
+	/* last round is special */   
+	*((word32*)temp[0]) = *((word32*)(b   )) ^ *((word32*)rk[1][0]);
+	*((word32*)temp[1]) = *((word32*)(b+ 4)) ^ *((word32*)rk[1][1]);
+	*((word32*)temp[2]) = *((word32*)(b+ 8)) ^ *((word32*)rk[1][2]);
+	*((word32*)temp[3]) = *((word32*)(b+12)) ^ *((word32*)rk[1][3]);
+	b[ 0] = S5[temp[0][0]];
+	b[ 1] = S5[temp[3][1]];
+	b[ 2] = S5[temp[2][2]];
+	b[ 3] = S5[temp[1][3]];
+	b[ 4] = S5[temp[1][0]];
+	b[ 5] = S5[temp[0][1]];
+	b[ 6] = S5[temp[3][2]];
+	b[ 7] = S5[temp[2][3]];
+	b[ 8] = S5[temp[2][0]];
+	b[ 9] = S5[temp[1][1]];
+	b[10] = S5[temp[0][2]];
+	b[11] = S5[temp[3][3]];
+	b[12] = S5[temp[3][0]];
+	b[13] = S5[temp[2][1]];
+	b[14] = S5[temp[1][2]];
+	b[15] = S5[temp[0][3]];
+	*((word32*)(b   )) ^= *((word32*)rk[0][0]);
+	*((word32*)(b+ 4)) ^= *((word32*)rk[0][1]);
+	*((word32*)(b+ 8)) ^= *((word32*)rk[0][2]);
+	*((word32*)(b+12)) ^= *((word32*)rk[0][3]);
+
+	return 0;
+}
+
+#ifdef INTERMEDIATE_VALUE_KAT
+/**
+ * Decrypt only a certain number of rounds.
+ * Only used in the Intermediate Value Known Answer Test.
+ * Operations rearranged such that the intermediate values
+ * of decryption correspond with the intermediate values
+ * of encryption.
+ */
+int rijndaelDecryptRound(word8 a[4][4], word8 rk[MAXROUNDS+1][4][4], int ROUNDS, int rounds) {
+	int r, i;
+	word8 temp[4], shift;
+
+	/* make number of rounds sane */
+	if (rounds > ROUNDS) {
+		rounds = ROUNDS;
+	}
+    /* first round is special: */
+	*(word32 *)a[0] ^= *(word32 *)rk[ROUNDS][0];
+	*(word32 *)a[1] ^= *(word32 *)rk[ROUNDS][1];
+	*(word32 *)a[2] ^= *(word32 *)rk[ROUNDS][2];
+	*(word32 *)a[3] ^= *(word32 *)rk[ROUNDS][3];
+	for (i = 0; i < 4; i++) {
+		a[i][0] = Si[a[i][0]];
+		a[i][1] = Si[a[i][1]];
+		a[i][2] = Si[a[i][2]];
+		a[i][3] = Si[a[i][3]];
+	}
+	for (i = 1; i < 4; i++) {
+		shift = (4 - i) & 3;
+		temp[0] = a[(0 + shift) & 3][i];
+		temp[1] = a[(1 + shift) & 3][i];
+		temp[2] = a[(2 + shift) & 3][i];
+		temp[3] = a[(3 + shift) & 3][i];
+		a[0][i] = temp[0];
+		a[1][i] = temp[1];
+		a[2][i] = temp[2];
+		a[3][i] = temp[3];
+	}
+	/* ROUNDS-1 ordinary rounds */
+	for (r = ROUNDS-1; r > rounds; r--) {
+		*(word32 *)a[0] ^= *(word32 *)rk[r][0];
+		*(word32 *)a[1] ^= *(word32 *)rk[r][1];
+		*(word32 *)a[2] ^= *(word32 *)rk[r][2];
+		*(word32 *)a[3] ^= *(word32 *)rk[r][3];
+
+		*((word32*)a[0]) =
+			  *((word32*)U1[a[0][0]])
+			^ *((word32*)U2[a[0][1]])
+			^ *((word32*)U3[a[0][2]])
+			^ *((word32*)U4[a[0][3]]);
+
+		*((word32*)a[1]) =
+			  *((word32*)U1[a[1][0]])
+			^ *((word32*)U2[a[1][1]])
+			^ *((word32*)U3[a[1][2]])
+			^ *((word32*)U4[a[1][3]]);
+
+		*((word32*)a[2]) =
+			  *((word32*)U1[a[2][0]])
+			^ *((word32*)U2[a[2][1]])
+			^ *((word32*)U3[a[2][2]])
+			^ *((word32*)U4[a[2][3]]);
+
+		*((word32*)a[3]) =
+			  *((word32*)U1[a[3][0]])
+			^ *((word32*)U2[a[3][1]])
+			^ *((word32*)U3[a[3][2]])
+			^ *((word32*)U4[a[3][3]]);
+		for (i = 0; i < 4; i++) {
+			a[i][0] = Si[a[i][0]];
+			a[i][1] = Si[a[i][1]];
+			a[i][2] = Si[a[i][2]];
+			a[i][3] = Si[a[i][3]];
+		}
+		for (i = 1; i < 4; i++) {
+			shift = (4 - i) & 3;
+			temp[0] = a[(0 + shift) & 3][i];
+			temp[1] = a[(1 + shift) & 3][i];
+			temp[2] = a[(2 + shift) & 3][i];
+			temp[3] = a[(3 + shift) & 3][i];
+			a[0][i] = temp[0];
+			a[1][i] = temp[1];
+			a[2][i] = temp[2];
+			a[3][i] = temp[3];
+		}
+	}
+	if (rounds == 0) {
+		/* End with the extra key addition */	
+		*(word32 *)a[0] ^= *(word32 *)rk[0][0];
+		*(word32 *)a[1] ^= *(word32 *)rk[0][1];
+		*(word32 *)a[2] ^= *(word32 *)rk[0][2];
+		*(word32 *)a[3] ^= *(word32 *)rk[0][3];
+	}    
+	return 0;
+}
+#endif /* INTERMEDIATE_VALUE_KAT */

Added: experimental/j/Elphel333/rtp/daemon/rtp/rijndael-alg-fst.h
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/rijndael-alg-fst.h	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/rijndael-alg-fst.h	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,40 @@
+/*
+ * rijndael-alg-fst.h   v2.4   April '2000
+ *
+ * Optimised ANSI C code
+ *
+ * #define INTERMEDIATE_VALUE_KAT to generate the Intermediate Value Known Answer Test.
+ */
+
+#ifndef __RIJNDAEL_ALG_FST_H
+#define __RIJNDAEL_ALG_FST_H
+
+#define BINARY_KEY_MATERIAL
+#define MAXKC			(256/32)
+#define MAXROUNDS		14
+
+#ifndef USUAL_TYPES
+#define USUAL_TYPES
+typedef unsigned char	byte;
+typedef unsigned char	word8;	
+typedef unsigned short	word16;	
+typedef unsigned int	word32;
+#endif /* USUAL_TYPES */
+
+int rijndaelKeySched(word8 k[MAXKC][4], word8 rk[MAXROUNDS+1][4][4], int ROUNDS);
+
+int rijndaelKeyEncToDec(word8 W[MAXROUNDS+1][4][4], int ROUNDS);
+
+int rijndaelEncrypt(word8 a[16], word8 b[16], word8 rk[MAXROUNDS+1][4][4], int ROUNDS);
+
+#ifdef INTERMEDIATE_VALUE_KAT
+int rijndaelEncryptRound(word8 a[4][4], word8 rk[MAXROUNDS+1][4][4], int ROUNDS, int rounds);
+#endif /* INTERMEDIATE_VALUE_KAT */
+
+int rijndaelDecrypt(word8 a[16], word8 b[16], word8 rk[MAXROUNDS+1][4][4], int ROUNDS);
+
+#ifdef INTERMEDIATE_VALUE_KAT
+int rijndaelDecryptRound(word8 a[4][4], word8 rk[MAXROUNDS+1][4][4], int ROUNDS, int rounds);
+#endif /* INTERMEDIATE_VALUE_KAT */
+
+#endif /* __RIJNDAEL_ALG_FST_H */

Added: experimental/j/Elphel333/rtp/daemon/rtp/rijndael-api-fst.c
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/rijndael-api-fst.c	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/rijndael-api-fst.c	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,498 @@
+/*
+ * rijndael-api-fst.c   v2.4   April '2000
+ *
+ * Optimised ANSI C code
+ *
+ * authors: v1.0: Antoon Bosselaers
+ *          v2.0: Vincent Rijmen
+ *          v2.1: Vincent Rijmen
+ *          v2.2: Vincent Rijmen
+ *          v2.3: Paulo Barreto
+ *          v2.4: Vincent Rijmen
+ *
+ * This code is placed in the public domain.
+ */
+
+#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "rijndael-alg-fst.h"
+#include "rijndael-api-fst.h"
+
+int makeKey(keyInstance *key, BYTE direction, int keyLen, char *keyMaterial) {
+	word8 k[MAXKC][4];
+	int i;
+	char *keyMat;
+	
+	if (key == NULL) {
+		return BAD_KEY_INSTANCE;
+	}
+
+	if ((direction == DIR_ENCRYPT) || (direction == DIR_DECRYPT)) {
+		key->direction = direction;
+	} else {
+		return BAD_KEY_DIR;
+	}
+
+	if ((keyLen == 128) || (keyLen == 192) || (keyLen == 256)) { 
+		key->keyLen = keyLen;
+	} else {
+		return BAD_KEY_MAT;
+	}
+
+	if (keyMaterial != NULL) {
+		strncpy(key->keyMaterial, keyMaterial, keyLen/4);
+	}
+
+	key->ROUNDS = keyLen/32 + 6;
+
+	/* initialize key schedule: */
+	keyMat = key->keyMaterial;
+#ifndef BINARY_KEY_MATERIAL
+ 	for (i = 0; i < key->keyLen/8; i++) {
+		int t, j;
+
+		t = *keyMat++;
+		if ((t >= '0') && (t <= '9')) j = (t - '0') << 4;
+		else if ((t >= 'a') && (t <= 'f')) j = (t - 'a' + 10) << 4; 
+		else if ((t >= 'A') && (t <= 'F')) j = (t - 'A' + 10) << 4; 
+		else return BAD_KEY_MAT;
+		
+		t = *keyMat++;
+		if ((t >= '0') && (t <= '9')) j ^= (t - '0');
+		else if ((t >= 'a') && (t <= 'f')) j ^= (t - 'a' + 10); 
+		else if ((t >= 'A') && (t <= 'F')) j ^= (t - 'A' + 10); 
+		else return BAD_KEY_MAT;
+		
+		k[i >> 2][i & 3] = (word8)j; 
+	}
+#else
+	for (i = 0; i < key->keyLen/8; i++) {
+		k[i >> 2][i & 3] = (word8)keyMat[i]; 
+	}
+#endif /* ?BINARY_KEY_MATERIAL */
+	rijndaelKeySched(k, key->keySched, key->ROUNDS);
+	if (direction == DIR_DECRYPT) {
+		rijndaelKeyEncToDec(key->keySched, key->ROUNDS);
+	}
+
+	return TRUE;
+}
+
+int cipherInit(cipherInstance *cipher, BYTE mode, char *IV) {
+	if ((mode == MODE_ECB) || (mode == MODE_CBC) || (mode == MODE_CFB1)) {
+		cipher->mode = mode;
+	} else {
+		return BAD_CIPHER_MODE;
+	}
+	if (IV != NULL) {
+#ifndef BINARY_KEY_MATERIAL
+		int i;
+ 		for (i = 0; i < MAX_IV_SIZE; i++) {
+			int t, j;
+
+			t = IV[2*i];
+			if ((t >= '0') && (t <= '9')) j = (t - '0') << 4;
+			else if ((t >= 'a') && (t <= 'f')) j = (t - 'a' + 10) << 4; 
+			else if ((t >= 'A') && (t <= 'F')) j = (t - 'A' + 10) << 4; 
+			else return BAD_CIPHER_INSTANCE;
+		
+			t = IV[2*i+1];
+			if ((t >= '0') && (t <= '9')) j ^= (t - '0');
+			else if ((t >= 'a') && (t <= 'f')) j ^= (t - 'a' + 10); 
+			else if ((t >= 'A') && (t <= 'F')) j ^= (t - 'A' + 10); 
+			else return BAD_CIPHER_INSTANCE;
+			
+			cipher->IV[i] = (word8)j;
+		}
+#else
+		memcpy(cipher->IV, IV, MAX_IV_SIZE);
+#endif /* ?BINARY_KEY_MATERIAL */
+	} else {
+		memset(cipher->IV, 0, MAX_IV_SIZE);
+	}
+	return TRUE;
+}
+
+int blockEncrypt(cipherInstance *cipher, keyInstance *key,
+		BYTE *input, int inputLen, BYTE *outBuffer) {
+	int i, k, numBlocks;
+	word8 block[16], iv[4][4];
+
+	if (cipher == NULL ||
+		key == NULL ||
+		key->direction == DIR_DECRYPT) {
+		return BAD_CIPHER_STATE;
+	}
+	if (input == NULL || inputLen <= 0) {
+		return 0; /* nothing to do */
+	}
+
+	numBlocks = inputLen/128;
+	
+	switch (cipher->mode) {
+	case MODE_ECB: 
+		for (i = numBlocks; i > 0; i--) {
+			rijndaelEncrypt(input, outBuffer, key->keySched, key->ROUNDS);
+			input += 16;
+			outBuffer += 16;
+		}
+		break;
+		
+	case MODE_CBC:
+		((word32*)block)[0] = ((word32*)cipher->IV)[0] ^ ((word32*)input)[0];
+		((word32*)block)[1] = ((word32*)cipher->IV)[1] ^ ((word32*)input)[1];
+		((word32*)block)[2] = ((word32*)cipher->IV)[2] ^ ((word32*)input)[2];
+		((word32*)block)[3] = ((word32*)cipher->IV)[3] ^ ((word32*)input)[3];
+		rijndaelEncrypt(block, outBuffer, key->keySched, key->ROUNDS);
+		input += 16;
+		for (i = numBlocks - 1; i > 0; i--) {
+			((word32*)block)[0] = ((word32*)outBuffer)[0] ^ ((word32*)input)[0];
+			((word32*)block)[1] = ((word32*)outBuffer)[1] ^ ((word32*)input)[1];
+			((word32*)block)[2] = ((word32*)outBuffer)[2] ^ ((word32*)input)[2];
+			((word32*)block)[3] = ((word32*)outBuffer)[3] ^ ((word32*)input)[3];
+			outBuffer += 16;
+			rijndaelEncrypt(block, outBuffer, key->keySched, key->ROUNDS);
+			input += 16;
+		}
+		break;
+	
+	case MODE_CFB1:
+#if STRICT_ALIGN 
+		memcpy(iv, cipher->IV, 16); 
+#else  /* !STRICT_ALIGN */
+		*((word32*)iv[0]) = *((word32*)(cipher->IV   ));
+		*((word32*)iv[1]) = *((word32*)(cipher->IV+ 4));
+		*((word32*)iv[2]) = *((word32*)(cipher->IV+ 8));
+		*((word32*)iv[3]) = *((word32*)(cipher->IV+12));
+#endif /* ?STRICT_ALIGN */
+		for (i = numBlocks; i > 0; i--) {
+			for (k = 0; k < 128; k++) {
+				*((word32*) block    ) = *((word32*)iv[0]);
+				*((word32*)(block+ 4)) = *((word32*)iv[1]);
+				*((word32*)(block+ 8)) = *((word32*)iv[2]);
+				*((word32*)(block+12)) = *((word32*)iv[3]);
+				rijndaelEncrypt(block, block, key->keySched, key->ROUNDS);
+				outBuffer[k/8] ^= (block[0] & 0x80) >> (k & 7);
+				iv[0][0] = (iv[0][0] << 1) | (iv[0][1] >> 7);
+				iv[0][1] = (iv[0][1] << 1) | (iv[0][2] >> 7);
+				iv[0][2] = (iv[0][2] << 1) | (iv[0][3] >> 7);
+				iv[0][3] = (iv[0][3] << 1) | (iv[1][0] >> 7);
+				iv[1][0] = (iv[1][0] << 1) | (iv[1][1] >> 7);
+				iv[1][1] = (iv[1][1] << 1) | (iv[1][2] >> 7);
+				iv[1][2] = (iv[1][2] << 1) | (iv[1][3] >> 7);
+				iv[1][3] = (iv[1][3] << 1) | (iv[2][0] >> 7);
+				iv[2][0] = (iv[2][0] << 1) | (iv[2][1] >> 7);
+				iv[2][1] = (iv[2][1] << 1) | (iv[2][2] >> 7);
+				iv[2][2] = (iv[2][2] << 1) | (iv[2][3] >> 7);
+				iv[2][3] = (iv[2][3] << 1) | (iv[3][0] >> 7);
+				iv[3][0] = (iv[3][0] << 1) | (iv[3][1] >> 7);
+				iv[3][1] = (iv[3][1] << 1) | (iv[3][2] >> 7);
+				iv[3][2] = (iv[3][2] << 1) | (iv[3][3] >> 7);
+				iv[3][3] = (iv[3][3] << 1) | ((outBuffer[k/8] >> (7-(k&7))) & 1);
+			}
+		}
+		break;
+	
+	default:
+		return BAD_CIPHER_STATE;
+	}
+	
+	return 128*numBlocks;
+}
+
+/**
+ * Encrypt data partitioned in octets, using RFC 2040-like padding.
+ *
+ * @param   input           data to be encrypted (octet sequence)
+ * @param   inputOctets		input length in octets (not bits)
+ * @param   outBuffer       encrypted output data
+ *
+ * @return	length in octets (not bits) of the encrypted output buffer.
+ */
+int padEncrypt(cipherInstance *cipher, keyInstance *key,
+		BYTE *input, int inputOctets, BYTE *outBuffer) {
+	int i, numBlocks, padLen;
+	word8 block[16], *iv;
+
+	if (cipher == NULL ||
+		key == NULL ||
+		key->direction == DIR_DECRYPT) {
+		return BAD_CIPHER_STATE;
+	}
+	if (input == NULL || inputOctets <= 0) {
+		return 0; /* nothing to do */
+	}
+
+	numBlocks = inputOctets/16;
+
+	switch (cipher->mode) {
+	case MODE_ECB: 
+		for (i = numBlocks; i > 0; i--) {
+			rijndaelEncrypt(input, outBuffer, key->keySched, key->ROUNDS);
+			input += 16;
+			outBuffer += 16;
+		}
+		padLen = 16 - (inputOctets - 16*numBlocks);
+		assert(padLen > 0 && padLen <= 16);
+		memcpy(block, input, 16 - padLen);
+		memset(block + 16 - padLen, padLen, padLen);
+		rijndaelEncrypt(block, outBuffer, key->keySched, key->ROUNDS);
+		break;
+
+	case MODE_CBC:
+		iv = cipher->IV;
+		for (i = numBlocks; i > 0; i--) {
+			((word32*)block)[0] = ((word32*)input)[0] ^ ((word32*)iv)[0];
+			((word32*)block)[1] = ((word32*)input)[1] ^ ((word32*)iv)[1];
+			((word32*)block)[2] = ((word32*)input)[2] ^ ((word32*)iv)[2];
+			((word32*)block)[3] = ((word32*)input)[3] ^ ((word32*)iv)[3];
+			rijndaelEncrypt(block, outBuffer, key->keySched, key->ROUNDS);
+			iv = outBuffer;
+			input += 16;
+			outBuffer += 16;
+		}
+		padLen = 16 - (inputOctets - 16*numBlocks);
+		assert(padLen > 0 && padLen <= 16);
+		for (i = 0; i < 16 - padLen; i++) {
+			block[i] = input[i] ^ iv[i];
+		}
+		for (i = 16 - padLen; i < 16; i++) {
+			block[i] = (BYTE)padLen ^ iv[i];
+		}
+		rijndaelEncrypt(block, outBuffer, key->keySched, key->ROUNDS);
+		break;
+
+	default:
+		return BAD_CIPHER_STATE;
+	}
+
+	return 16*(numBlocks + 1);
+}
+
+int blockDecrypt(cipherInstance *cipher, keyInstance *key,
+		BYTE *input, int inputLen, BYTE *outBuffer) {
+	int i, k, numBlocks;
+	word8 block[16], iv[4][4];
+
+	if (cipher == NULL ||
+		key == NULL ||
+		(cipher->mode != MODE_CFB1 && key->direction == DIR_ENCRYPT)) {
+		return BAD_CIPHER_STATE;
+	}
+	if (input == NULL || inputLen <= 0) {
+		return 0; /* nothing to do */
+	}
+
+	numBlocks = inputLen/128;
+
+	switch (cipher->mode) {
+	case MODE_ECB: 
+		for (i = numBlocks; i > 0; i--) { 
+			rijndaelDecrypt(input, outBuffer, key->keySched, key->ROUNDS);
+			input += 16;
+			outBuffer += 16;
+		}
+		break;
+		
+	case MODE_CBC:
+#if STRICT_ALIGN 
+		memcpy(iv, cipher->IV, 16); 
+#else
+		*((word32*)iv[0]) = *((word32*)(cipher->IV   ));
+		*((word32*)iv[1]) = *((word32*)(cipher->IV+ 4));
+		*((word32*)iv[2]) = *((word32*)(cipher->IV+ 8));
+		*((word32*)iv[3]) = *((word32*)(cipher->IV+12));
+#endif
+		for (i = numBlocks; i > 0; i--) {
+			rijndaelDecrypt(input, block, key->keySched, key->ROUNDS);
+			((word32*)block)[0] ^= *((word32*)iv[0]);
+			((word32*)block)[1] ^= *((word32*)iv[1]);
+			((word32*)block)[2] ^= *((word32*)iv[2]);
+			((word32*)block)[3] ^= *((word32*)iv[3]);
+#if STRICT_ALIGN
+			memcpy(iv, input, 16);
+			memcpy(outBuf, block, 16);
+#else
+			*((word32*)iv[0]) = ((word32*)input)[0]; ((word32*)outBuffer)[0] = ((word32*)block)[0];
+			*((word32*)iv[1]) = ((word32*)input)[1]; ((word32*)outBuffer)[1] = ((word32*)block)[1];
+			*((word32*)iv[2]) = ((word32*)input)[2]; ((word32*)outBuffer)[2] = ((word32*)block)[2];
+			*((word32*)iv[3]) = ((word32*)input)[3]; ((word32*)outBuffer)[3] = ((word32*)block)[3];
+#endif
+			input += 16;
+			outBuffer += 16;
+		}
+		break;
+	
+	case MODE_CFB1:
+#if STRICT_ALIGN 
+		memcpy(iv, cipher->IV, 16); 
+#else
+		*((word32*)iv[0]) = *((word32*)(cipher->IV));
+		*((word32*)iv[1]) = *((word32*)(cipher->IV+ 4));
+		*((word32*)iv[2]) = *((word32*)(cipher->IV+ 8));
+		*((word32*)iv[3]) = *((word32*)(cipher->IV+12));
+#endif
+		for (i = numBlocks; i > 0; i--) {
+			for (k = 0; k < 128; k++) {
+				*((word32*) block    ) = *((word32*)iv[0]);
+				*((word32*)(block+ 4)) = *((word32*)iv[1]);
+				*((word32*)(block+ 8)) = *((word32*)iv[2]);
+				*((word32*)(block+12)) = *((word32*)iv[3]);
+				rijndaelEncrypt(block, block, key->keySched, key->ROUNDS);
+				iv[0][0] = (iv[0][0] << 1) | (iv[0][1] >> 7);
+				iv[0][1] = (iv[0][1] << 1) | (iv[0][2] >> 7);
+				iv[0][2] = (iv[0][2] << 1) | (iv[0][3] >> 7);
+				iv[0][3] = (iv[0][3] << 1) | (iv[1][0] >> 7);
+				iv[1][0] = (iv[1][0] << 1) | (iv[1][1] >> 7);
+				iv[1][1] = (iv[1][1] << 1) | (iv[1][2] >> 7);
+				iv[1][2] = (iv[1][2] << 1) | (iv[1][3] >> 7);
+				iv[1][3] = (iv[1][3] << 1) | (iv[2][0] >> 7);
+				iv[2][0] = (iv[2][0] << 1) | (iv[2][1] >> 7);
+				iv[2][1] = (iv[2][1] << 1) | (iv[2][2] >> 7);
+				iv[2][2] = (iv[2][2] << 1) | (iv[2][3] >> 7);
+				iv[2][3] = (iv[2][3] << 1) | (iv[3][0] >> 7);
+				iv[3][0] = (iv[3][0] << 1) | (iv[3][1] >> 7);
+				iv[3][1] = (iv[3][1] << 1) | (iv[3][2] >> 7);
+				iv[3][2] = (iv[3][2] << 1) | (iv[3][3] >> 7);
+				iv[3][3] = (iv[3][3] << 1) | ((input[k/8] >> (7-(k&7))) & 1);
+				outBuffer[k/8] ^= (block[0] & 0x80) >> (k & 7);
+			}
+		}
+		break;
+
+	default:
+		return BAD_CIPHER_STATE;
+	}
+	
+	return 128*numBlocks;
+}
+
+int padDecrypt(cipherInstance *cipher, keyInstance *key,
+		BYTE *input, int inputOctets, BYTE *outBuffer) {
+	int i, numBlocks, padLen;
+	word8 block[16];
+	word32 iv[4];
+
+	if (cipher == NULL ||
+		key == NULL ||
+		key->direction == DIR_ENCRYPT) {
+		return BAD_CIPHER_STATE;
+	}
+	if (input == NULL || inputOctets <= 0) {
+		return 0; /* nothing to do */
+	}
+	if (inputOctets % 16 != 0) {
+		return BAD_DATA;
+	}
+
+	numBlocks = inputOctets/16;
+
+	switch (cipher->mode) {
+	case MODE_ECB:
+		/* all blocks but last */
+		for (i = numBlocks - 1; i > 0; i--) { 
+			rijndaelDecrypt(input, outBuffer, key->keySched, key->ROUNDS);
+			input += 16;
+			outBuffer += 16;
+		}
+		/* last block */
+		rijndaelDecrypt(input, block, key->keySched, key->ROUNDS);
+		padLen = block[15];
+		if (padLen >= 16) {
+			return BAD_DATA;
+		}
+		for (i = 16 - padLen; i < 16; i++) {
+			if (block[i] != padLen) {
+				return BAD_DATA;
+			}
+		}
+		memcpy(outBuffer, block, 16 - padLen);
+		break;
+		
+	case MODE_CBC:
+		memcpy(iv, cipher->IV, 16);
+		/* all blocks but last */
+		for (i = numBlocks - 1; i > 0; i--) {
+			rijndaelDecrypt(input, block, key->keySched, key->ROUNDS);
+			((word32*)block)[0] ^= iv[0];
+			((word32*)block)[1] ^= iv[1];
+			((word32*)block)[2] ^= iv[2];
+			((word32*)block)[3] ^= iv[3];
+			memcpy(iv, input, 16);
+			memcpy(outBuffer, block, 16);
+			input += 16;
+			outBuffer += 16;
+		}
+		/* last block */
+		rijndaelDecrypt(input, block, key->keySched, key->ROUNDS);
+		((word32*)block)[0] ^= iv[0];
+		((word32*)block)[1] ^= iv[1];
+		((word32*)block)[2] ^= iv[2];
+		((word32*)block)[3] ^= iv[3];
+		padLen = block[15];
+		if (padLen <= 0 || padLen > 16) {
+			return BAD_DATA;
+		}
+		for (i = 16 - padLen; i < 16; i++) {
+			if (block[i] != padLen) {
+				return BAD_DATA;
+			}
+		}
+		memcpy(outBuffer, block, 16 - padLen);
+		break;
+	
+	default:
+		return BAD_CIPHER_STATE;
+	}
+	
+	return 16*numBlocks - padLen;
+}
+
+#ifdef INTERMEDIATE_VALUE_KAT
+/**
+ *	cipherUpdateRounds:
+ *
+ *	Encrypts/Decrypts exactly one full block a specified number of rounds.
+ *	Only used in the Intermediate Value Known Answer Test.	
+ *
+ *	Returns:
+ *		TRUE - on success
+ *		BAD_CIPHER_STATE - cipher in bad state (e.g., not initialized)
+ */
+int cipherUpdateRounds(cipherInstance *cipher, keyInstance *key,
+		BYTE *input, int inputLen, BYTE *outBuffer, int rounds) {
+	int j;
+	word8 block[4][4];
+
+	if (cipher == NULL || key == NULL) {
+		return BAD_CIPHER_STATE;
+	}
+
+	for (j = 3; j >= 0; j--) {
+		/* parse input stream into rectangular array */
+  		*((word32*)block[j]) = *((word32*)(input+4*j));
+	}
+
+	switch (key->direction) {
+	case DIR_ENCRYPT:
+		rijndaelEncryptRound(block, key->keySched, key->ROUNDS, rounds);
+		break;
+		
+	case DIR_DECRYPT:
+		rijndaelDecryptRound(block, key->keySched, key->ROUNDS, rounds);
+		break;
+		
+	default:
+		return BAD_KEY_DIR;
+	} 
+
+	for (j = 3; j >= 0; j--) {
+		/* parse rectangular array into output ciphertext bytes */
+		*((word32*)(outBuffer+4*j)) = *((word32*)block[j]);
+	}
+	
+	return TRUE;
+}
+#endif /* INTERMEDIATE_VALUE_KAT */

Added: experimental/j/Elphel333/rtp/daemon/rtp/rijndael-api-fst.h
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/rijndael-api-fst.h	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/rijndael-api-fst.h	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,100 @@
+/*
+ * rijndael-api-fst.h   v2.4   April '2000
+ *
+ * Optimised ANSI C code
+ *
+ * #define INTERMEDIATE_VALUE_KAT to generate the Intermediate Value Known Answer Test.
+ */
+
+#ifndef __RIJNDAEL_API_FST_H
+#define __RIJNDAEL_API_FST_H
+
+#include <stdio.h>
+#include "rijndael-alg-fst.h"
+
+/*  Defines:
+	Add any additional defines you need
+*/
+
+#define     DIR_ENCRYPT           0 /*  Are we encrpyting?  */
+#define     DIR_DECRYPT           1 /*  Are we decrpyting?  */
+#define     MODE_ECB              1 /*  Are we ciphering in ECB mode?   */
+#define     MODE_CBC              2 /*  Are we ciphering in CBC mode?   */
+#define     MODE_CFB1             3 /*  Are we ciphering in 1-bit CFB mode? */
+#define     TRUE                  1
+#define     FALSE                 0
+#define     BITSPERBLOCK        128 /* Default number of bits in a cipher block */
+
+/*  Error Codes - CHANGE POSSIBLE: inclusion of additional error codes  */
+#define     BAD_KEY_DIR          -1 /*  Key direction is invalid, e.g., unknown value */
+#define     BAD_KEY_MAT          -2 /*  Key material not of correct length */
+#define     BAD_KEY_INSTANCE     -3 /*  Key passed is not valid */
+#define     BAD_CIPHER_MODE      -4 /*  Params struct passed to cipherInit invalid */
+#define     BAD_CIPHER_STATE     -5 /*  Cipher in wrong state (e.g., not initialized) */
+#define     BAD_BLOCK_LENGTH     -6
+#define     BAD_CIPHER_INSTANCE  -7
+#define     BAD_DATA             -8 /*  Data contents are invalid, e.g., invalid padding */
+#define     BAD_OTHER            -9 /*  Unknown error */
+
+/*  CHANGE POSSIBLE:  inclusion of algorithm specific defines  */
+#define     MAX_KEY_SIZE         64 /* # of ASCII char's needed to represent a key */
+#define     MAX_IV_SIZE          16 /* # bytes needed to represent an IV  */
+
+/*  Typedefs:
+
+	Typedef'ed data storage elements.  Add any algorithm specific 
+parameters at the bottom of the structs as appropriate.
+*/
+
+typedef unsigned char   BYTE;
+
+/*  The structure for key information */
+typedef struct {
+    BYTE  direction;                /* Key used for encrypting or decrypting? */
+    int   keyLen;                   /* Length of the key  */
+    char  keyMaterial[MAX_KEY_SIZE+1];  /* Raw key data in ASCII, e.g., user input or KAT values */
+        /*  The following parameters are algorithm dependent, replace or add as necessary  */
+	int   ROUNDS;                   /* key-length-dependent number of rounds */
+    int   blockLen;                 /* block length */
+    word8 keySched[MAXROUNDS+1][4][4];	/* key schedule		*/
+} keyInstance;
+
+/*  The structure for cipher information */
+typedef struct {                    /* changed order of the components */
+    BYTE  mode;                     /* MODE_ECB, MODE_CBC, or MODE_CFB1 */
+    BYTE  IV[MAX_IV_SIZE];          /* A possible Initialization Vector for ciphering */
+        /*  Add any algorithm specific parameters needed here  */
+    int   blockLen;                 /* Sample: Handles non-128 bit block sizes (if available) */
+} cipherInstance;
+
+/*  Function prototypes  */
+/*  CHANGED: nothing
+	TODO: implement the following extensions to setup 192-bit and 256-bit block lengths:
+        makeKeyEx():    parameter blockLen added
+                        -- this parameter is absolutely necessary if you want to
+                        setup the round keys in a variable block length setting 
+	    cipherInitEx(): parameter blockLen added (for obvious reasons)		
+ */
+
+int makeKey(keyInstance *key, BYTE direction, int keyLen, char *keyMaterial);
+
+int cipherInit(cipherInstance *cipher, BYTE mode, char *IV);
+
+int blockEncrypt(cipherInstance *cipher, keyInstance *key,
+        BYTE *input, int inputLen, BYTE *outBuffer);
+
+int padEncrypt(cipherInstance *cipher, keyInstance *key,
+		BYTE *input, int inputOctets, BYTE *outBuffer);
+
+int blockDecrypt(cipherInstance *cipher, keyInstance *key,
+        BYTE *input, int inputLen, BYTE *outBuffer);
+
+int padDecrypt(cipherInstance *cipher, keyInstance *key,
+		BYTE *input, int inputOctets, BYTE *outBuffer);
+
+#ifdef INTERMEDIATE_VALUE_KAT
+int cipherUpdateRounds(cipherInstance *cipher, keyInstance *key,
+        BYTE *input, int inputLen, BYTE *outBuffer, int Rounds);
+#endif /* INTERMEDIATE_VALUE_KAT */
+
+#endif /*  __RIJNDAEL_API_FST_H */

Added: experimental/j/Elphel333/rtp/daemon/rtp/rtp.c
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/rtp.c	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/rtp.c	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,3432 @@
+/*
+ * FILE:     rtp.c
+ * AUTHOR:   Colin Perkins   <csp at isi.edu>
+ * MODIFIED: Orion Hodson    <o.hodson at cs.ucl.ac.uk>
+ *           Markus Germeier <mager at tzi.de>
+ *           Bill Fenner     <fenner at research.att.com>
+ *           Timur Friedman  <timur at research.att.com>
+ *
+ * The routines in this file implement the Real-time Transport Protocol,
+ * RTP, as specified in RFC1889 with current updates under discussion in
+ * the IETF audio/video transport working group. Portions of the code are
+ * derived from the algorithms published in that specification.
+ *
+ * $Revision: 1.1.1.1 $ 
+ * $Date: 2005/03/18 09:18:05 $
+ * 
+ * Copyright (c) 1998-2001 University College London
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, is permitted provided that the following conditions 
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by the Computer Science
+ *      Department at University College London.
+ * 4. Neither the name of the University nor of the Department may be used
+ *    to endorse or promote products derived from this software without
+ *    specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#include "config_unix.h"
+#include "config_win32.h"
+#include "memory.h"
+#include "debug.h"
+#include "net_udp.h"
+#include "crypt_random.h"
+#include "rijndael-api-fst.h"
+#include "drand48.h"
+#include "gettimeofday.h"
+#include "qfDES.h"
+#include "md5.h"
+#include "ntp.h"
+
+#include "rtp.h"
+typedef struct {
+        uint32_t key;   /* Original allocation number   */
+        uint32_t size;  /* Size of allocation requested */
+        uint32_t pad;   /* Alignment padding to 8 bytes */
+        uint32_t magic; /* Magic number                 */
+} chk_header;
+	  extern int chk_header_okay(const chk_header *ch);
+
+/*
+ * Encryption stuff.
+ */
+#define MAX_ENCRYPTION_PAD 16
+
+static int rijndael_initialize(struct rtp *session, u_char *hash, int hash_len);
+
+static int rijndael_decrypt(void *ifptr, uint8_t *data,
+		    unsigned int *size);
+static int rijndael_encrypt(void *ifptr, uint8_t *data,
+	    unsigned int *size);
+
+static int des_initialize(struct rtp *session, u_char *hash, int hash_len);
+static int des_decrypt(void *ifptr, uint8_t *data,
+	       unsigned int *size);
+static int des_encrypt(void *ifptr, uint8_t *data,
+	       unsigned int *size);
+
+#define MAX_DROPOUT    3000
+#define MAX_MISORDER   100
+#define MIN_SEQUENTIAL 2
+
+/*
+ * Definitions for the RTP/RTCP packets on the wire...
+ */
+
+#define RTP_SEQ_MOD        0x10000
+#define RTP_MAX_SDES_LEN   256
+
+#define RTP_LOWER_LAYER_OVERHEAD 28	/* IPv4 + UDP */
+
+#define RTCP_SR   200
+#define RTCP_RR   201
+#define RTCP_SDES 202
+#define RTCP_BYE  203
+#define RTCP_APP  204
+
+typedef struct {
+#ifdef WORDS_BIGENDIAN
+	unsigned short  version:2;	/* packet type            */
+	unsigned short  p:1;		/* padding flag           */
+	unsigned short  count:5;	/* varies by payload type */
+	unsigned short  pt:8;		/* payload type           */
+#else
+	unsigned short  count:5;	/* varies by payload type */
+	unsigned short  p:1;		/* padding flag           */
+	unsigned short  version:2;	/* packet type            */
+	unsigned short  pt:8;		/* payload type           */
+#endif
+	uint16_t        length;		/* packet length          */
+} rtcp_common;
+
+typedef struct {
+	rtcp_common   common;	
+	union {
+		struct {
+			rtcp_sr		sr;
+			rtcp_rr       	rr[1];		/* variable-length list */
+		} sr;
+		struct {
+			uint32_t        ssrc;		/* source this RTCP packet is coming from */
+			rtcp_rr       	rr[1];		/* variable-length list */
+		} rr;
+		struct rtcp_sdes_t {
+			uint32_t	ssrc;
+			rtcp_sdes_item 	item[1];	/* list of SDES */
+		} sdes;
+		struct {
+			uint32_t        ssrc[1];	/* list of sources */
+							/* can't express the trailing text... */
+		} bye;
+		struct {
+			uint32_t        ssrc;           
+			uint8_t         name[4];
+			uint8_t         data[1];
+		} app;
+	} r;
+} rtcp_t;
+
+typedef struct _rtcp_rr_wrapper {
+	struct _rtcp_rr_wrapper	*next;
+	struct _rtcp_rr_wrapper	*prev;
+        uint32_t                 reporter_ssrc;
+	rtcp_rr			*rr;
+	struct timeval		*ts;	/* Arrival time of this RR */
+} rtcp_rr_wrapper;
+
+/*
+ * The RTP database contains source-specific information needed 
+ * to make it all work. 
+ */
+
+typedef struct _source {
+	struct _source	*next;
+	struct _source	*prev;
+	uint32_t	 ssrc;
+	char		*cname;
+	char		*name;
+	char		*email;
+	char		*phone;
+	char		*loc;
+	char		*tool;
+	char		*note;
+	char		*priv;
+	rtcp_sr		*sr;
+	struct timeval	 last_sr;
+	struct timeval	 last_active;
+	int		 should_advertise_sdes;	/* TRUE if this source is a CSRC which we need to advertise SDES for */
+	int		 sender;
+	int		 got_bye;		/* TRUE if we've received an RTCP bye from this source */
+	uint32_t	 base_seq;
+	uint16_t	 max_seq;
+	uint32_t	 bad_seq;
+	uint32_t	 cycles;
+	int		 received;
+	int		 received_prior;
+	int		 expected_prior;
+	int		 probation;
+	uint32_t	 jitter;
+	uint32_t	 transit;
+	uint32_t	 magic;			/* For debugging... */
+} source;
+
+/* The size of the hash table used to hold the source database. */
+/* Should be large enough that we're unlikely to get collisions */
+/* when sources are added, but not too large that we waste too  */
+/* much memory. Sedgewick ("Algorithms", 2nd Ed, Addison-Wesley */
+/* 1988) suggests that this should be around 1/10th the number  */
+/* of entries that we expect to have in the database and should */
+/* be a prime number. Everything continues to work if this is   */
+/* too low, it just goes slower... for now we assume around 100 */
+/* participants is a sensible limit so we set this to 11.       */   
+#define RTP_DB_SIZE	11
+
+/*
+ *  Options for an RTP session are stored in the "options" struct.
+ */
+
+typedef struct {
+	int 	promiscuous_mode;
+	int	wait_for_rtcp;
+	int	filter_my_packets;
+} options;
+
+/*
+ * Encryption function types
+ */
+
+// moved to rtp.h by nori
+/*
+ * typedef int (*rtp_encrypt_func)(struct rtp *, unsigned char *data,
+ *				unsigned int size);
+ *
+ * typedef int (*rtp_decrypt_func)(struct rtp *, unsigned char *data,
+ *				unsigned int size);
+ */
+typedef int (*rtcp_send_f)(struct rtp *s, uint8_t *buffer, int buflen);
+
+/*
+ * The "struct rtp" defines an RTP session.
+ */
+
+struct rtp {
+	socket_udp	*rtp_socket;
+	socket_udp	*rtcp_socket;
+	char		*addr;
+	uint16_t	 rx_port;
+	uint16_t	 tx_port;
+	int		 ttl;
+	uint32_t	 my_ssrc;
+	int		 last_advertised_csrc;
+	source		*db[RTP_DB_SIZE];
+        rtcp_rr_wrapper  rr[RTP_DB_SIZE][RTP_DB_SIZE]; 	/* Indexed by [hash(reporter)][hash(reportee)] */
+	options		*opt;
+	uint8_t		*userdata;
+	int		 invalid_rtp_count;
+	int		 invalid_rtcp_count;
+	int		 bye_count;
+	int		 csrc_count;
+	int		 ssrc_count;
+	int		 ssrc_count_prev;		/* ssrc_count at the time we last recalculated our RTCP interval */
+	int		 sender_count;
+	int		 initial_rtcp;
+	int		 sending_bye;			/* TRUE if we're in the process of sending a BYE packet */
+	double		 avg_rtcp_size;
+	int		 we_sent;
+	double		 rtcp_bw;			/* RTCP bandwidth fraction, in octets per second. */
+	struct timeval	 last_update;
+	struct timeval	 last_rtp_send_time;
+	struct timeval	 last_rtcp_send_time;
+	struct timeval	 next_rtcp_send_time;
+	double		 rtcp_interval;
+	int		 sdes_count_pri;
+	int		 sdes_count_sec;
+	int		 sdes_count_ter;
+	uint16_t	 rtp_seq;
+	uint32_t	 rtp_pcount;
+	uint32_t	 rtp_bcount;
+    char *encryption_algorithm;
+ 	int encryption_enabled;
+ 	rtp_encrypt_func encrypt_func;
+ 	rtp_decrypt_func decrypt_func;
+ 	int encryption_pad_length;
+  int encryption_lenadd;
+  void *encrypt_userdata; // added by nori
+ 	union {
+ 		struct {
+ 			keyInstance keyInstEncrypt;
+ 			keyInstance keyInstDecrypt;
+ 			cipherInstance cipherInst;
+ 		} rijndael;
+ 		struct {
+ 			char            *encryption_key;
+ 		} des;
+ 	} crypto_state;
+	rtp_callback	 callback;
+  rtcp_send_f rtcp_send;
+  rtcp_send_packet_t rtcp_send_packet;
+	uint32_t	 magic;				/* For debugging...  */
+};
+
+static int filter_event(struct rtp *session, uint32_t ssrc)
+{
+	int	filter;
+
+	rtp_get_option(session, RTP_OPT_FILTER_MY_PACKETS, &filter);
+	return filter && (ssrc == rtp_my_ssrc(session));
+}
+
+static double tv_diff(struct timeval curr_time, struct timeval prev_time)
+{
+    /* Return curr_time - prev_time */
+    double	ct, pt;
+
+    ct = (double) curr_time.tv_sec + (((double) curr_time.tv_usec) / 1000000.0);
+    pt = (double) prev_time.tv_sec + (((double) prev_time.tv_usec) / 1000000.0);
+    return (ct - pt);
+}
+
+static void tv_add(struct timeval *ts, double offset)
+{
+	/* Add offset seconds to ts */
+	double offset_sec, offset_usec;
+
+	offset_usec = modf(offset, &offset_sec) * 1000000;
+	ts->tv_sec  += (long) offset_sec;
+	ts->tv_usec += (long) offset_usec;
+	if (ts->tv_usec > 1000000) {
+		ts->tv_sec++;
+		ts->tv_usec -= 1000000;
+	}
+}
+
+static int tv_gt(struct timeval a, struct timeval b)
+{
+	/* Returns (a>b) */
+	if (a.tv_sec > b.tv_sec) {
+		return TRUE;
+	}
+	if (a.tv_sec < b.tv_sec) {
+		return FALSE;
+	}
+	ASSERT(a.tv_sec == b.tv_sec);
+	return a.tv_usec > b.tv_usec;
+}
+
+static uint32_t next_csrc(struct rtp *session)
+{
+	/* This returns each source marked "should_advertise_sdes" in turn. */
+	int	 chain, cc;
+	source	*s;
+
+	cc = 0;
+	for (chain = 0; chain < RTP_DB_SIZE; chain++) {
+		/* Check that the linked lists making up the chains in */
+		/* the hash table are correctly linked together...     */
+		for (s = session->db[chain]; s != NULL; s = s->next) {
+			if (s->should_advertise_sdes) {
+				if (cc == session->last_advertised_csrc) {
+                                        session->last_advertised_csrc++;
+                                        if (session->last_advertised_csrc == session->csrc_count) {
+                                                session->last_advertised_csrc = 0;
+                                        }
+					return s->ssrc;
+				} else {
+					cc++;
+				}
+			}
+		}
+	}
+	/* We should never get here... */
+	abort();
+}
+
+static int ssrc_hash(uint32_t ssrc)
+{
+	/* Hash from an ssrc to a position in the source database.   */
+	/* Assumes that ssrc values are uniformly distributed, which */
+	/* should be true but probably isn't (Rosenberg has reported */
+	/* that many implementations generate ssrc values which are  */
+	/* not uniformly distributed over the space, and the H.323   */
+	/* spec requires that they are non-uniformly distributed).   */
+	/* This routine is written as a function rather than inline  */
+	/* code to allow it to be made smart in future: probably we  */
+	/* should run MD5 on the ssrc and derive a hash value from   */
+	/* that, to ensure it's more uniformly distributed?          */
+	return ssrc % RTP_DB_SIZE;
+}
+
+static void insert_rr(struct rtp *session, uint32_t reporter_ssrc, rtcp_rr *rr, struct timeval *ts)
+{
+        /* Insert the reception report into the receiver report      */
+        /* database. This database is a two dimensional table of     */
+        /* rr_wrappers indexed by hashes of reporter_ssrc and        */
+        /* reportee_src.  The rr_wrappers in the database are        */
+        /* sentinels to reduce conditions in list operations.        */
+	/* The ts is used to determine when to timeout this rr.      */
+
+        rtcp_rr_wrapper *cur, *start;
+
+        start = &session->rr[ssrc_hash(reporter_ssrc)][ssrc_hash(rr->ssrc)];
+        cur   = start->next;
+
+        while (cur != start) {
+                if (cur->reporter_ssrc == reporter_ssrc && cur->rr->ssrc == rr->ssrc) {
+                        /* Replace existing entry in the database  */
+                        xfree(cur->rr);
+			xfree(cur->ts);
+                        cur->rr = rr;
+			cur->ts = (struct timeval *) xmalloc(sizeof(struct timeval));
+			memcpy(cur->ts, ts, sizeof(struct timeval));
+                        return;
+                }
+                cur = cur->next;
+        }
+        
+        /* No entry in the database so create one now. */
+        cur = (rtcp_rr_wrapper*)xmalloc(sizeof(rtcp_rr_wrapper));
+        cur->reporter_ssrc = reporter_ssrc;
+        cur->rr = rr;
+	cur->ts = (struct timeval *) xmalloc(sizeof(struct timeval));
+	memcpy(cur->ts, ts, sizeof(struct timeval));
+        /* Fix links */
+        cur->next       = start->next;
+        cur->next->prev = cur;
+        cur->prev       = start;
+        cur->prev->next = cur;
+
+        rtp_message(LOG_INFO, "Created new rr entry for 0x%08x from source 0x%08x", rr->ssrc, reporter_ssrc);
+        return;
+}
+
+static void remove_rr(struct rtp *session, uint32_t ssrc)
+{
+	/* Remove any RRs from "s" which refer to "ssrc" as either   */
+        /* reporter or reportee.                                     */
+        rtcp_rr_wrapper *start, *cur, *tmp;
+        int i;
+
+        /* Remove rows, i.e. ssrc == reporter_ssrc                   */
+        for(i = 0; i < RTP_DB_SIZE; i++) {
+                start = &session->rr[ssrc_hash(ssrc)][i];
+                cur   = start->next;
+                while (cur != start) {
+                        if (cur->reporter_ssrc == ssrc) {
+                                tmp = cur;
+                                cur = cur->prev;
+                                tmp->prev->next = tmp->next;
+                                tmp->next->prev = tmp->prev;
+				xfree(tmp->ts);
+                                xfree(tmp->rr);
+                                xfree(tmp);
+                        }
+                        cur = cur->next;
+                }
+        }
+
+        /* Remove columns, i.e.  ssrc == reporter_ssrc */
+        for(i = 0; i < RTP_DB_SIZE; i++) {
+                start = &session->rr[i][ssrc_hash(ssrc)];
+                cur   = start->next;
+                while (cur != start) {
+                        if (cur->rr->ssrc == ssrc) {
+                                tmp = cur;
+                                cur = cur->prev;
+                                tmp->prev->next = tmp->next;
+                                tmp->next->prev = tmp->prev;
+				xfree(tmp->ts);
+                                xfree(tmp->rr);
+                                xfree(tmp);
+                        }
+                        cur = cur->next;
+                }
+        }
+}
+
+static void timeout_rr(struct rtp *session, struct timeval *curr_ts)
+{
+	/* Timeout any reception reports which have been in the database for more than 3 */
+	/* times the RTCP reporting interval without refresh.                            */
+        rtcp_rr_wrapper *start, *cur, *tmp;
+	rtp_event	 event;
+        int 		 i, j;
+
+        for(i = 0; i < RTP_DB_SIZE; i++) {
+        	for(j = 0; j < RTP_DB_SIZE; j++) {
+			start = &session->rr[i][j];
+			cur   = start->next;
+			while (cur != start) {
+				if (tv_diff(*curr_ts, *(cur->ts)) > (session->rtcp_interval * 3)) {
+					/* Signal the application... */
+					if (!filter_event(session, cur->reporter_ssrc)) {
+						event.ssrc = cur->reporter_ssrc;
+						event.type = RR_TIMEOUT;
+						event.data = cur->rr;
+						event.ts   = curr_ts;
+						session->callback(session, &event);
+					}
+					/* Delete this reception report... */
+					tmp = cur;
+					cur = cur->prev;
+					tmp->prev->next = tmp->next;
+					tmp->next->prev = tmp->prev;
+					xfree(tmp->ts);
+					xfree(tmp->rr);
+					xfree(tmp);
+				}
+				cur = cur->next;
+			}
+		}
+	}
+}
+
+static const rtcp_rr* get_rr(struct rtp *session, uint32_t reporter_ssrc, uint32_t reportee_ssrc)
+{
+        rtcp_rr_wrapper *cur, *start;
+
+        start = &session->rr[ssrc_hash(reporter_ssrc)][ssrc_hash(reportee_ssrc)];
+        cur   = start->next;
+        while (cur != start) {
+                if (cur->reporter_ssrc == reporter_ssrc &&
+                    cur->rr->ssrc      == reportee_ssrc) {
+                        return cur->rr;
+                }
+                cur = cur->next;
+        }
+        return NULL;
+}
+
+static void check_source(source *s)
+{
+	ASSERT(s != NULL);
+	ASSERT(s->magic == 0xc001feed);
+}
+
+static void check_database(struct rtp *session)
+{
+	/* This routine performs a sanity check on the database. */
+	/* This should not call any of the other routines which  */
+	/* manipulate the database, to avoid common failures.    */
+#ifdef DEBUG
+	source 	 	*s;
+	int	 	 source_count;
+	int		 chain;
+#endif
+	ASSERT(session != NULL);
+	ASSERT(session->magic == 0xfeedface);
+#ifdef DEBUG
+	/* Check that we have a database entry for our ssrc... */
+	/* We only do this check if ssrc_count > 0 since it is */
+	/* performed during initialisation whilst creating the */
+	/* source entry for my_ssrc.                           */
+	if (session->ssrc_count > 0) {
+		for (s = session->db[ssrc_hash(session->my_ssrc)]; s != NULL; s = s->next) {
+			if (s->ssrc == session->my_ssrc) {
+				break;
+			}
+		}
+		ASSERT(s != NULL);
+	}
+
+	source_count = 0;
+	for (chain = 0; chain < RTP_DB_SIZE; chain++) {
+		/* Check that the linked lists making up the chains in */
+		/* the hash table are correctly linked together...     */
+		for (s = session->db[chain]; s != NULL; s = s->next) {
+			check_source(s);
+			source_count++;
+			if (s->prev == NULL) {
+				ASSERT(s == session->db[chain]);
+			} else {
+				ASSERT(s->prev->next == s);
+			}
+			if (s->next != NULL) {
+				ASSERT(s->next->prev == s);
+			}
+			/* Check that the SR is for this source... */
+			if (s->sr != NULL) {
+			  if (s->sr->ssrc != s->ssrc) {
+			    rtp_message(LOG_CRIT, "database error ssrc sr->ssrc is %d should be %d",
+					s->sr->ssrc, s->ssrc);
+				ASSERT(s->sr->ssrc == s->ssrc);
+			  }
+			}
+		}
+	}
+	/* Check that the number of entries in the hash table  */
+	/* matches session->ssrc_count                         */
+	ASSERT(source_count == session->ssrc_count);
+	if (source_count != session->ssrc_count) {
+	  rtp_message(LOG_DEBUG, "source count %d does not equal session count %d", source_count, session->ssrc_count);
+	}
+#endif
+}
+
+static source *get_source(struct rtp *session, uint32_t ssrc)
+{
+	source *s;
+
+	check_database(session);
+	for (s = session->db[ssrc_hash(ssrc)]; s != NULL; s = s->next) {
+		if (s->ssrc == ssrc) {
+			check_source(s);
+			return s;
+		}
+	}
+	return NULL;
+}
+
+static source *create_source(struct rtp *session, uint32_t ssrc, int probation)
+{
+	/* Create a new source entry, and add it to the database.    */
+	/* The database is a hash table, using the separate chaining */
+	/* algorithm.                                                */
+	rtp_event	 event;
+	struct timeval	 event_ts;
+	source		*s = get_source(session, ssrc);
+	int		 h;
+
+	if (s != NULL) {
+		/* Source is already in the database... Mark it as */
+		/* active and exit (this is the common case...)    */
+		gettimeofday(&(s->last_active), NULL);
+		return s;
+	}
+	check_database(session);
+	/* This is a new source, we have to create it... */
+	h = ssrc_hash(ssrc);
+	s = (source *) xmalloc(sizeof(source));
+	memset(s, 0, sizeof(source));
+	s->magic          = 0xc001feed;
+	s->next           = session->db[h];
+	s->ssrc           = ssrc;
+	if (probation) {
+		/* This is a probationary source, which only counts as */
+		/* valid once several consecutive packets are received */
+		s->probation = -1;
+	} else {
+		s->probation = 0;
+	}
+
+	gettimeofday(&(s->last_active), NULL);
+	/* Now, add it to the database... */
+	if (session->db[h] != NULL) {
+		session->db[h]->prev = s;
+	}
+	session->db[ssrc_hash(ssrc)] = s;
+	session->ssrc_count++;
+	check_database(session);
+
+	rtp_message(LOG_INFO, "Created database entry for ssrc 0x%08x (%d valid sources)", ssrc, session->ssrc_count);
+        if (ssrc != session->my_ssrc) {
+                /* Do not send during rtp_init since application cannot map the address */
+                /* of the rtp session to anything since rtp_init has not returned yet.  */
+		if (!filter_event(session, ssrc)) {
+			gettimeofday(&event_ts, NULL);
+			event.ssrc = ssrc;
+			event.type = SOURCE_CREATED;
+			event.data = NULL;
+			event.ts   = &event_ts;
+			session->callback(session, &event);
+		}
+        }
+
+	return s;
+}
+
+static void delete_source(struct rtp *session, uint32_t ssrc)
+{
+	/* Remove a source from the RTP database... */
+	source		*s = get_source(session, ssrc);
+	int		 h = ssrc_hash(ssrc);
+	rtp_event	 event;
+	struct timeval	 event_ts;
+
+	ASSERT(s != NULL);	/* Deleting a source which doesn't exist is an error... */
+
+	gettimeofday(&event_ts, NULL);
+
+	check_source(s);
+	check_database(session);
+	if (session->db[h] == s) {
+		/* It's the first entry in this chain... */
+		session->db[h] = s->next;
+		if (s->next != NULL) {
+			s->next->prev = NULL;
+		}
+	} else {
+		ASSERT(s->prev != NULL);	/* Else it would be the first in the chain... */
+		s->prev->next = s->next;
+		if (s->next != NULL) {
+			s->next->prev = s->prev;
+		}
+	}
+	/* Free the memory allocated to a source... */
+	if (s->cname != NULL) xfree(s->cname);
+	if (s->name  != NULL) xfree(s->name);
+	if (s->email != NULL) xfree(s->email);
+	if (s->phone != NULL) xfree(s->phone);
+	if (s->loc   != NULL) xfree(s->loc);
+	if (s->tool  != NULL) xfree(s->tool);
+	if (s->note  != NULL) xfree(s->note);
+	if (s->priv  != NULL) xfree(s->priv);
+	if (s->sr    != NULL) xfree(s->sr);
+
+        remove_rr(session, ssrc); 
+
+	/* Reduce our SSRC count, and perform reverse reconsideration on the RTCP */
+	/* reporting interval (draft-ietf-avt-rtp-new-05.txt, section 6.3.4). To  */
+	/* make the transmission rate of RTCP packets more adaptive to changes in */
+	/* group membership, the following "reverse reconsideration" algorithm    */
+	/* SHOULD be executed when a BYE packet is received that reduces members  */
+	/* to a value less than pmembers:                                         */
+	/* o  The value for tn is updated according to the following formula:     */
+	/*       tn = tc + (members/pmembers)(tn - tc)                            */
+	/* o  The value for tp is updated according the following formula:        */
+	/*       tp = tc - (members/pmembers)(tc - tp).                           */
+	/* o  The next RTCP packet is rescheduled for transmission at time tn,    */
+	/*    which is now earlier.                                               */
+	/* o  The value of pmembers is set equal to members.                      */
+	session->ssrc_count--;
+	if (session->ssrc_count < session->ssrc_count_prev) {
+		gettimeofday(&(session->next_rtcp_send_time), NULL);
+		gettimeofday(&(session->last_rtcp_send_time), NULL);
+		tv_add(&(session->next_rtcp_send_time), (session->ssrc_count / session->ssrc_count_prev) 
+						     * tv_diff(session->next_rtcp_send_time, event_ts));
+		tv_add(&(session->last_rtcp_send_time), - ((session->ssrc_count / session->ssrc_count_prev) 
+						     * tv_diff(event_ts, session->last_rtcp_send_time)));
+		session->ssrc_count_prev = session->ssrc_count;
+	}
+
+	/* Reduce our csrc count... */
+	if (s->should_advertise_sdes == TRUE) {
+		session->csrc_count--;
+	}
+	if (session->last_advertised_csrc == session->csrc_count) {
+		session->last_advertised_csrc = 0;
+	}
+
+	/* Signal to the application that this source is dead... */
+	if (!filter_event(session, ssrc)) {
+		event.ssrc = ssrc;
+		event.type = SOURCE_DELETED;
+		event.data = NULL;
+		event.ts   = &event_ts;
+		session->callback(session, &event);
+	}
+        xfree(s);
+	check_database(session);
+}
+
+static void init_seq(source *s, uint16_t seq)
+{
+	/* Taken from draft-ietf-avt-rtp-new-01.txt */
+	check_source(s);
+	s->base_seq = seq;
+	s->max_seq = seq;
+	s->bad_seq = RTP_SEQ_MOD + 1;
+	s->cycles = 0;
+	s->received = 0;
+	s->received_prior = 0;
+	s->expected_prior = 0;
+}
+
+static int update_seq(source *s, uint16_t seq)
+{
+	/* Taken from draft-ietf-avt-rtp-new-01.txt */
+	uint16_t udelta = seq - s->max_seq;
+
+	/*
+	 * Source is not valid until MIN_SEQUENTIAL packets with
+	 * sequential sequence numbers have been received.
+	 */
+	check_source(s);
+	if (s->probation) {
+		  /* packet is in sequence */
+		  if (seq == s->max_seq + 1) {
+				s->probation--;
+				s->max_seq = seq;
+				if (s->probation == 0) {
+					 init_seq(s, seq);
+					 s->received++;
+					 return 1;
+				}
+		  } else {
+				s->probation = MIN_SEQUENTIAL - 1;
+				s->max_seq = seq;
+		  }
+		  return 0;
+	} else if (udelta < MAX_DROPOUT) {
+		  /* in order, with permissible gap */
+		  if (seq < s->max_seq) {
+				/*
+				 * Sequence number wrapped - count another 64K cycle.
+				 */
+				s->cycles += RTP_SEQ_MOD;
+		  }
+		  s->max_seq = seq;
+	} else if (udelta <= RTP_SEQ_MOD - MAX_MISORDER) {
+		  /* the sequence number made a very large jump */
+		  if (seq == s->bad_seq) {
+				/*
+				 * Two sequential packets -- assume that the other side
+				 * restarted without telling us so just re-sync
+				 * (i.e., pretend this was the first packet).
+				 */
+				init_seq(s, seq);
+		  } else {
+				s->bad_seq = (seq + 1) & (RTP_SEQ_MOD-1);
+				return 0;
+		  }
+	} else {
+		  /* duplicate or reordered packet */
+	}
+	s->received++;
+	return 1;
+}
+
+static double rtcp_interval(struct rtp *session)
+{
+	/* Minimum average time between RTCP packets from this site (in   */
+	/* seconds).  This time prevents the reports from `clumping' when */
+	/* sessions are small and the law of large numbers isn't helping  */
+	/* to smooth out the traffic.  It also keeps the report interval  */
+	/* from becoming ridiculously small during transient outages like */
+	/* a network partition.                                           */
+	double const RTCP_MIN_TIME = 5.0;
+	/* Fraction of the RTCP bandwidth to be shared among active       */
+	/* senders.  (This fraction was chosen so that in a typical       */
+	/* session with one or two active senders, the computed report    */
+	/* time would be roughly equal to the minimum report time so that */
+	/* we don't unnecessarily slow down receiver reports.) The        */
+	/* receiver fraction must be 1 - the sender fraction.             */
+	double const RTCP_SENDER_BW_FRACTION = 0.25;
+	double const RTCP_RCVR_BW_FRACTION   = (1-RTCP_SENDER_BW_FRACTION);
+	/* To compensate for "unconditional reconsideration" converging   */
+	/* to a value below the intended average.                         */
+	double const COMPENSATION            = 2.71828 - 1.5;
+
+	double t;				              /* interval */
+	double rtcp_min_time = RTCP_MIN_TIME;
+	int n;			        /* no. of members for computation */
+	double rtcp_bw = session->rtcp_bw;
+
+	/* Very first call at application start-up uses half the min      */
+	/* delay for quicker notification while still allowing some time  */
+	/* before reporting for randomization and to learn about other    */
+	/* sources so the report interval will converge to the correct    */
+	/* interval more quickly.                                         */
+	if (session->initial_rtcp) {
+		rtcp_min_time /= 2;
+	}
+
+	/* If there were active senders, give them at least a minimum     */
+	/* share of the RTCP bandwidth.  Otherwise all participants share */
+	/* the RTCP bandwidth equally.                                    */
+	if (session->sending_bye) {
+		n = session->bye_count;
+	} else {
+		n = session->ssrc_count;
+	}
+	if (session->sender_count > 0 && session->sender_count < n * RTCP_SENDER_BW_FRACTION) {
+		if (session->we_sent) {
+			rtcp_bw *= RTCP_SENDER_BW_FRACTION;
+			n = session->sender_count;
+		} else {
+			rtcp_bw *= RTCP_RCVR_BW_FRACTION;
+			n -= session->sender_count;
+		}
+	}
+
+	/* The effective number of sites times the average packet size is */
+	/* the total number of octets sent when each site sends a report. */
+	/* Dividing this by the effective bandwidth gives the time        */
+	/* interval over which those packets must be sent in order to     */
+	/* meet the bandwidth target, with a minimum enforced.  In that   */
+	/* time interval we send one report so this time is also our      */
+	/* average time between reports.                                  */
+	t = session->avg_rtcp_size * n / rtcp_bw;
+	if (t < rtcp_min_time) {
+		t = rtcp_min_time;
+	}
+	session->rtcp_interval = t;
+
+	/* To avoid traffic bursts from unintended synchronization with   */
+	/* other sites, we then pick our actual next report interval as a */
+	/* random number uniformly distributed between 0.5*t and 1.5*t.   */
+	return (t * (drand48() + 0.5)) / COMPENSATION;
+}
+
+#define MAXCNAMELEN	255
+
+static char *get_cname(socket_udp *s)
+{
+        /* Set the CNAME. This is "user at hostname" or just "hostname" if the username cannot be found. */
+        char              *hname;
+        char                    *uname;
+        char                    *cname;
+#ifndef WIN32
+        struct passwd           *pwent;
+#else
+        char *name;
+        int   namelen;
+#endif
+
+        cname = (char *) xmalloc(MAXCNAMELEN + 1);
+        cname[0] = '\0';
+
+        /* First, fill in the username... */
+#ifdef WIN32
+        name = NULL;
+        namelen = 0;
+        GetUserName(NULL, &namelen);
+        if (namelen > 0) {
+                name = (char*)xmalloc(namelen+1);
+                GetUserName(name, &namelen);
+        } else {
+                uname = getenv("USER");
+                if (uname != NULL) {
+                        name = xstrdup(uname);
+                }
+        }
+        if (name != NULL) {
+                strncpy(cname, name, MAXCNAMELEN - 1);
+                strcat(cname, "@");
+                xfree(name);
+        }
+#else
+        pwent = getpwuid(getuid());
+        uname = pwent->pw_name;
+        if (uname != NULL) {
+                strncpy(cname, uname, MAXCNAMELEN - 1);
+                strcat(cname, "@");
+        }
+
+#endif
+        
+        /* Now the hostname. Must be dotted-quad IP address. */
+        hname = udp_host_addr(s);
+	if (hname == NULL) {
+		/* If we can't get our IP address we use the loopback address... */
+		/* This is horrible, but it stops the code from failing.         */
+	  strncpy(cname + strlen(cname),
+		  "127.0.0.1",
+		  MAXCNAMELEN - strlen(cname));
+	} else {
+	  strncpy(cname + strlen(cname), hname, MAXCNAMELEN - strlen(cname));
+	  xfree(hname);
+	}
+        return cname;
+}
+
+static void init_opt(struct rtp *session)
+{
+	/* Default option settings. */
+	rtp_set_option(session, RTP_OPT_PROMISC,           FALSE);
+	rtp_set_option(session, RTP_OPT_WEAK_VALIDATION,   TRUE);
+	rtp_set_option(session, RTP_OPT_FILTER_MY_PACKETS, FALSE);
+}
+
+static void init_rng(const char *s)
+{
+        static uint32_t seed;
+	if (s == NULL) s = "ARANDOMSTRINGSOWEDONTCOREDUMP";
+        if (seed == 0) {
+                pid_t p = getpid();
+		int32_t i, n;
+                while (*s) {
+                        seed += (uint32_t)*s++;
+                        seed = seed * 31 + 1;
+                }
+                seed = 1 + seed * 31 + (uint32_t)p;
+                srand48(seed);
+		/* At time of writing we use srand48 -> srand on Win32
+                   which is only 16 bit. lrand48 -> rand which is only
+                   15 bits, step a long way through table seq */
+#ifdef WIN32
+		n = (seed >> 16) & 0xffff;
+		for(i = 0; i < n; i++) {
+			seed = lrand48();
+		}
+#endif /* WIN32 */
+		UNUSED(i);
+		UNUSED(n);
+	}
+}
+
+/* See rtp_init_if(); calling rtp_init() is just like calling
+ * rtp_init_if() with a NULL interface argument.
+ */
+
+/**
+ * rtp_init:
+ * @addr: IP destination of this session (unicast or multicast),
+ * as an ASCII string.  May be a host name, which will be looked up,
+ * or may be an IPv4 dotted quad or IPv6 literal adddress.
+ * @rx_port: The port to which to bind the UDP socket
+ * @tx_port: The port to which to send UDP packets
+ * @ttl: The TTL with which to send multicasts
+ * @rtcp_bw: The total bandwidth (in units of bytes per second) that is
+ * allocated to RTCP.
+ * @callback: See section on #rtp_callback.
+ * @userdata: Opaque data associated with the session.  See
+ * rtp_get_userdata().
+ *
+ *
+ * Returns: An opaque session identifier to be used in future calls to
+ * the RTP library functions, or NULL on failure.
+ */
+struct rtp *rtp_init(const char *addr, 
+		     uint16_t rx_port, uint16_t tx_port, 
+		     int ttl, double rtcp_bw, 
+                     rtp_callback callback,
+                     uint8_t *userdata)
+{
+	return rtp_init_if(addr, NULL, rx_port, tx_port, ttl, rtcp_bw, callback, userdata, 0);
+}
+
+struct rtp *rtp_init_xmitter (const char *addr, 
+			      uint16_t rx_port, uint16_t tx_port,
+			      int ttl, double rtcp_bw, 
+			      rtp_callback callback, 
+			      uint8_t *userdata)
+{
+  struct rtp *session = rtp_init(addr, rx_port, tx_port, ttl, rtcp_bw,
+			callback, userdata);
+
+  gettimeofday(&(session->next_rtcp_send_time), NULL);
+  return session;
+}
+
+static int rtcp_local_send (struct rtp *session, uint8_t *buffer, int buflen)
+{
+  return (session->rtcp_send_packet)(session->userdata, buffer, buflen);
+}
+
+static int rtcp_udp_send (struct rtp *session, uint8_t *buffer, int buflen)
+{
+  return (udp_send(session->rtcp_socket, buffer, buflen));
+}
+
+struct rtp *rtp_init_extern_net (const char *addr, 
+				 uint16_t rx_port, uint16_t tx_port, 
+				 int ttl, double rtcp_bw, 
+				 rtp_callback callback,
+				 rtcp_send_packet_t rtcp_send_packet,
+				 uint8_t *userdata)
+{
+  rtp_t rtp_ptr = rtp_init_if(addr, NULL, rx_port, tx_port, ttl, rtcp_bw, callback, userdata, 1);
+  if (rtp_ptr == NULL) return NULL;
+  rtp_ptr->rtcp_send = rtcp_local_send;
+  rtp_ptr->rtcp_send_packet = rtcp_send_packet;
+  return (rtp_ptr);
+}
+/**
+ * rtp_init_if:
+ * @addr: IP destination of this session (unicast or multicast),
+ * as an ASCII string.  May be a host name, which will be looked up,
+ * or may be an IPv4 dotted quad or IPv6 literal adddress.
+ * @iface: If the destination of the session is multicast,
+ * the optional interface to bind to.  May be NULL, in which case
+ * the default multicast interface as determined by the system
+ * will be used.
+ * @rx_port: The port to which to bind the UDP socket
+ * @tx_port: The port to which to send UDP packets
+ * @ttl: The TTL with which to send multicasts
+ * @rtcp_bw: The total bandwidth (in units of ___) that is
+ * allocated to RTCP.
+ * @callback: See section on #rtp_callback.
+ * @userdata: Opaque data associated with the session.  See
+ * rtp_get_userdata().
+ *
+ * Creates and initializes an RTP session.
+ *
+ * Returns: An opaque session identifier to be used in future calls to
+ * the RTP library functions, or NULL on failure.
+ */
+struct rtp *rtp_init_if(const char *addr, char *iface, 
+			uint16_t rx_port, uint16_t tx_port, 
+			int ttl, double rtcp_bw, 
+                        rtp_callback callback,
+                        uint8_t *userdata,
+			int dont_init_sockets)
+{
+	struct rtp 	*session;
+	int         	 i, j;
+	char		*cname;
+	char *hname;
+
+        if (ttl < 0) {
+                rtp_message(LOG_CRIT, "ttl must be greater than zero");
+                return NULL;
+        }
+        if (rx_port % 2) {
+                rtp_message(LOG_CRIT, "rx_port must be even");
+                return NULL;
+        }
+        if (tx_port % 2) {
+                rtp_message(LOG_CRIT, "tx_port must be even");
+                return NULL;
+        }
+
+	session 		= (struct rtp *) xmalloc(sizeof(struct rtp));
+	session->crypto_state.des.encryption_key = NULL;
+	session->magic		= 0xfeedface;
+	session->opt		= (options *) xmalloc(sizeof(options));
+	session->userdata	= userdata;
+	session->addr		= xstrdup(addr);
+	session->rx_port	= rx_port;
+	session->tx_port	= tx_port;
+	session->ttl		= min(ttl, 127);
+
+	init_opt(session);
+
+	if (dont_init_sockets == 0) {
+	  session->rtp_socket	= udp_init_if(addr, iface, rx_port, tx_port, ttl);
+	  session->rtcp_socket = udp_init_if(addr, iface, (uint16_t) (rx_port ? rx_port + 1 : 0), (uint16_t) (tx_port + 1), ttl);
+
+	  if (session->rtp_socket == NULL || session->rtcp_socket == NULL) {
+	    xfree(session);
+	    return NULL;
+	  }
+	} else {
+	  session->rtp_socket = NULL;
+	  session->rtcp_socket = NULL;
+	}
+
+	hname = udp_host_addr(session->rtp_socket);
+        init_rng(hname);
+	if (hname != NULL) {
+	  xfree(hname);
+	}
+
+	session->my_ssrc            = (uint32_t) lrand48();
+	session->rtcp_send          = rtcp_udp_send;
+	session->callback           = callback;
+	session->invalid_rtp_count  = 0;
+	session->invalid_rtcp_count = 0;
+	session->bye_count          = 0;
+	session->csrc_count         = 0;
+	session->ssrc_count         = 0;
+	session->ssrc_count_prev    = 0;
+	session->sender_count       = 0;
+	session->initial_rtcp       = TRUE;
+	session->sending_bye        = FALSE;
+	session->avg_rtcp_size      = -1;	/* Sentinal value: reception of first packet starts initial value... */
+	session->we_sent            = FALSE;
+	session->rtcp_bw            = rtcp_bw;
+	session->sdes_count_pri     = 0;
+	session->sdes_count_sec     = 0;
+	session->sdes_count_ter     = 0;
+	session->rtp_seq            = (uint16_t) lrand48();
+	session->rtp_pcount         = 0;
+	session->rtp_bcount         = 0;
+	gettimeofday(&(session->last_update), NULL);
+	gettimeofday(&(session->last_rtcp_send_time), NULL);
+	gettimeofday(&(session->next_rtcp_send_time), NULL);
+        session->encryption_enabled = 0;
+	session->encryption_algorithm = NULL;
+
+	/* Calculate when we're supposed to send our first RTCP packet... */
+	tv_add(&(session->next_rtcp_send_time), rtcp_interval(session));
+
+	/* Initialise the source database... */
+	for (i = 0; i < RTP_DB_SIZE; i++) {
+		session->db[i] = NULL;
+	}
+	session->last_advertised_csrc = 0;
+
+        /* Initialize sentinels in rr table */
+        for (i = 0; i < RTP_DB_SIZE; i++) {
+                for (j = 0; j < RTP_DB_SIZE; j++) {
+                        session->rr[i][j].next = &session->rr[i][j];
+                        session->rr[i][j].prev = &session->rr[i][j];
+                }
+        }
+
+	/* Create a database entry for ourselves... */
+	create_source(session, session->my_ssrc, FALSE);
+	cname = get_cname(session->rtp_socket);
+	rtp_set_sdes(session, session->my_ssrc, RTCP_SDES_CNAME, cname, strlen(cname));
+	xfree(cname);	/* cname is copied by rtp_set_sdes()... */
+
+	return session;
+}
+
+
+/**
+ * rtp_set_my_ssrc:
+ * @session: the RTP session 
+ * @ssrc: the SSRC to be used by the RTP session
+ * 
+ * This function coerces the local SSRC identifer to be ssrc.  For
+ * this function to succeed it must be called immediately after
+ * rtp_init or rtp_init_if.  The intended purpose of this
+ * function is to co-ordinate SSRC's between layered sessions, it
+ * should not be used otherwise.
+ *
+ * Returns: TRUE on success, FALSE otherwise.  
+ */
+int rtp_set_my_ssrc(struct rtp *session, uint32_t ssrc)
+{
+        source *s;
+        uint32_t h;
+
+        if (session->ssrc_count != 1 && session->sender_count != 0) {
+                return FALSE;
+        }
+        /* Remove existing source */
+        h = ssrc_hash(session->my_ssrc);
+        s = session->db[h];
+        session->db[h] = NULL;
+        /* Fill in new ssrc       */
+        session->my_ssrc = ssrc;
+        s->ssrc          = ssrc;
+        h                = ssrc_hash(ssrc);
+        /* Put source back        */
+        session->db[h]   = s;
+        return TRUE;
+}
+
+/**
+ * rtp_set_option:
+ * @session: The RTP session.
+ * @optname: The option name, see #rtp_option.
+ * @optval: The value to set.
+ *
+ * Sets the value of a session option.  See #rtp_option for
+ * documentation on the options and their legal values.
+ *
+ * Returns: TRUE on success, else FALSE.
+ */
+int rtp_set_option(struct rtp *session, rtp_option optname, int optval)
+{
+	ASSERT((optval == TRUE) || (optval == FALSE));
+
+	switch (optname) {
+		case RTP_OPT_WEAK_VALIDATION:
+			session->opt->wait_for_rtcp = optval;
+			break;
+	        case RTP_OPT_PROMISC:
+			session->opt->promiscuous_mode = optval;
+			break;
+	        case RTP_OPT_FILTER_MY_PACKETS:
+			session->opt->filter_my_packets = optval;
+			break;
+        	default:
+			rtp_message(LOG_ALERT, "Ignoring unknown option (%d) in call to rtp_set_option().", optname);
+                        return FALSE;
+	}
+        return TRUE;
+}
+
+/**
+ * rtp_get_option:
+ * @session: The RTP session.
+ * @optname: The option name, see #rtp_option.
+ * @optval: The return value.
+ *
+ * Retrieves the value of a session option.  See #rtp_option for
+ * documentation on the options and their legal values.
+ *
+ * Returns: TRUE and the value of the option in optval on success, else FALSE.
+ */
+int rtp_get_option(struct rtp *session, rtp_option optname, int *optval)
+{
+	switch (optname) {
+		case RTP_OPT_WEAK_VALIDATION:
+			*optval = session->opt->wait_for_rtcp;
+                        break;
+        	case RTP_OPT_PROMISC:
+			*optval = session->opt->promiscuous_mode;
+                        break;
+	        case RTP_OPT_FILTER_MY_PACKETS:
+			*optval = session->opt->filter_my_packets;
+			break;
+        	default:
+                        *optval = 0;
+			rtp_message(LOG_ALERT, "Ignoring unknown option (%d) in call to rtp_get_option().", optname);
+                        return FALSE;
+	}
+        return TRUE;
+}
+
+/**
+ * rtp_get_userdata:
+ * @session: The RTP session.
+ *
+ * This function returns the userdata pointer that was passed to the
+ * rtp_init() or rtp_init_if() function when creating this session.
+ *
+ * Returns: pointer to userdata.
+ */
+uint8_t *rtp_get_userdata(struct rtp *session)
+{
+	check_database(session);
+	return session->userdata;
+}
+
+/**
+ * rtp_my_ssrc:
+ * @session: The RTP Session.
+ *
+ * Returns: The SSRC we are currently using in this session. Note that our
+ * SSRC can change at any time (due to collisions) so applications must not
+ * store the value returned, but rather should call this function each time 
+ * they need it.
+ */
+uint32_t rtp_my_ssrc(struct rtp *session)
+{
+	check_database(session);
+	return session->my_ssrc;
+}
+
+static int validate_rtp(rtp_packet *packet, int len)
+{
+	/* This function checks the header info to make sure that the packet */
+	/* is valid. We return TRUE if the packet is valid, FALSE otherwise. */
+	/* See Appendix A.1 of the RTP specification.                        */
+
+	/* We only accept RTPv2 packets... */
+	if (packet->rtp_pak_v != 2) {
+		rtp_message(LOG_WARNING, "rtp_header_validation: v != 2");
+		return FALSE;
+	}
+	/* Check for valid payload types..... 72-76 are RTCP payload type numbers, with */
+	/* the high bit missing so we report that someone is running on the wrong port. */
+	if (packet->rtp_pak_pt >= 72 && packet->rtp_pak_pt <= 76) {
+		rtp_message(LOG_WARNING, "rtp_header_validation: payload-type invalid %d - seq%d", packet->rtp_pak_pt, packet->rtp_pak_seq);
+		if (packet->rtp_pak_m) {
+			rtp_message(LOG_WARNING, " (RTCP packet on RTP port?)");
+		}
+		return FALSE;
+	}
+	/* Check that the length of the packet is sensible... */
+	if (len < (12 + (4 * packet->rtp_pak_cc))) {
+		rtp_message(LOG_WARNING, "rtp_header_validation: packet length is smaller than the header");
+		return FALSE;
+	}
+	/* Check that the amount of padding specified is sensible. */
+	/* Note: have to include the size of any extension header! */
+	if (packet->rtp_pak_p) {
+		int	payload_len = len - 12 - (packet->rtp_pak_cc * 4);
+                if (packet->rtp_pak_x) {
+                        /* extension header and data */
+                        payload_len -= 4 * (1 + packet->rtp_extn_len);
+                }
+                if (packet->rtp_data[packet->rtp_data_len - 1] > payload_len) {
+                        rtp_message(LOG_WARNING, "rtp_header_validation: padding greater than payload length");
+                        return FALSE;
+                }
+                if (packet->rtp_data[packet->rtp_data_len - 1] < 1) {
+			rtp_message(LOG_WARNING, "rtp_header_validation: padding zero");
+			return FALSE;
+		}
+        }
+	return TRUE;
+}
+
+static void process_rtp(struct rtp *session, uint32_t curr_rtp_ts, rtp_packet *packet, source *s)
+{
+	int		 i, d, transit;
+	rtp_event	 event;
+	struct timeval	 event_ts;
+
+	if (packet->rtp_pak_cc > 0) {
+		for (i = 0; i < packet->rtp_pak_cc; i++) {
+			create_source(session, packet->rtp_csrc[i], FALSE);
+		}
+	}
+	/* Update the source database... */
+	if (s->sender == FALSE) {
+		s->sender = TRUE;
+		session->sender_count++;
+	}
+	transit    = curr_rtp_ts - packet->rtp_pak_ts;
+	d      	   = transit - s->transit;
+	s->transit = transit;
+	if (d < 0) {
+		d = -d;
+	}
+	s->jitter += d - ((s->jitter + 8) / 16);
+	
+	/* Callback to the application to process the packet... */
+	if (!filter_event(session, packet->rtp_pak_ssrc)) {
+		gettimeofday(&event_ts, NULL);
+		event.ssrc = packet->rtp_pak_ssrc;
+		event.type = RX_RTP;
+		event.data = (void *) packet;	/* The callback function MUST free this! */
+		event.ts   = &event_ts;
+		session->callback(session, &event);
+	}
+}
+
+int rtp_process_recv_data (struct rtp *session,
+			   uint32_t curr_rtp_ts,
+			   rtp_packet *packet,
+			   int buflen)
+{
+  uint8_t		*buffer = ((uint8_t *) packet) + RTP_PACKET_HEADER_SIZE;
+  source		*s;
+  int ret;
+
+  packet->pd.rtp_pd_buflen = buflen;
+
+  if (buflen > 0) {
+    if (session->encryption_enabled)
+      {
+	ret = (session->decrypt_func)(session->encrypt_userdata, buffer, &buflen);
+
+	if (ret != TRUE) return -1;
+	packet->pd.rtp_pd_buflen = buflen;
+      }
+    
+    /* Convert header fields to host byte order... */
+    packet->rtp_next = packet->rtp_prev = NULL;
+    packet->rtp_pak_seq  = ntohs(packet->rtp_pak_seq);
+    packet->rtp_pak_ts   = ntohl(packet->rtp_pak_ts);
+    packet->rtp_pak_ssrc = ntohl(packet->rtp_pak_ssrc);
+    /* Setup internal pointers, etc... */
+    if (packet->rtp_pak_cc) {
+      int	i;
+      packet->rtp_csrc = (uint32_t *)(buffer + 12);
+      for (i = 0; i < packet->rtp_pak_cc; i++) {
+	packet->rtp_csrc[i] = ntohl(packet->rtp_csrc[i]);
+      }
+    } else {
+      packet->rtp_csrc = NULL;
+    }
+    if (packet->rtp_pak_x) {
+      packet->rtp_extn      = buffer + 12 + (packet->rtp_pak_cc * 4);
+      packet->rtp_extn_len  = (packet->rtp_extn[2] << 8) | packet->rtp_extn[3];
+      packet->rtp_extn_type = (packet->rtp_extn[0] << 8) | packet->rtp_extn[1];
+    } else {
+      packet->rtp_extn      = NULL;
+      packet->rtp_extn_len  = 0;
+      packet->rtp_extn_type = 0;
+    }
+    packet->rtp_data     = buffer + 12 + (packet->rtp_pak_cc * 4);
+    packet->rtp_data_len = buflen -  (packet->rtp_pak_cc * 4) - 12;
+    if (packet->rtp_extn != NULL) {
+      packet->rtp_data += ((packet->rtp_extn_len + 1) * 4);
+      packet->rtp_data_len -= ((packet->rtp_extn_len + 1) * 4);
+    }
+    if (validate_rtp(packet, buflen)) {
+      int weak = 0, promisc = 0;
+      rtp_get_option(session, RTP_OPT_WEAK_VALIDATION, &weak);
+      if (weak) {
+	s = get_source(session, packet->rtp_pak_ssrc);
+      } else {
+	s = create_source(session, packet->rtp_pak_ssrc, TRUE);
+      }
+      rtp_get_option(session, RTP_OPT_PROMISC, &promisc);
+      if (promisc) {
+	if (s == NULL) {
+	  create_source(session, packet->rtp_pak_ssrc, FALSE);
+	  s = get_source(session, packet->rtp_pak_ssrc);
+	}
+	if (s->probation == -1) {
+	  s->probation = MIN_SEQUENTIAL;
+	  s->max_seq = packet->rtp_pak_seq - 1;
+	}
+	update_seq(s, packet->rtp_pak_seq);
+	  
+	process_rtp(session, curr_rtp_ts, packet, s);
+	return 0; /* We don't free "packet", that's done by the callback function... */
+      } 
+      if (s != NULL) {
+	if (s->probation == -1) {
+	  s->probation = MIN_SEQUENTIAL;
+	  s->max_seq   = packet->rtp_pak_seq - 1;
+	}
+	if (update_seq(s, packet->rtp_pak_seq)) {
+	  process_rtp(session, curr_rtp_ts, packet, s);
+	  return 0;	/* we don't free "packet", that's done by the callback function... */
+	} else {
+	  /* This source is still on probation... */
+	  rtp_message(LOG_INFO, "RTP packet from probationary source ignored...");
+	}
+      } else {
+	rtp_message(LOG_WARNING, "RTP packet from unknown source %d ignored", packet->rtp_pak_ssrc);
+      }
+    } else {
+      session->invalid_rtp_count++;
+      rtp_message(LOG_INFO, "Invalid RTP packet discarded");
+    }
+  }
+  return -1; /* We need to free the packet */
+}
+
+void rtp_recv_data(struct rtp *session, uint32_t curr_rtp_ts)
+{
+	/* This routine preprocesses an incoming RTP packet, deciding whether to process it. */
+	rtp_packet	*packet = (rtp_packet *) xmalloc(RTP_MAX_PACKET_LEN + RTP_PACKET_HEADER_SIZE);
+	uint8_t		*buffer = ((uint8_t *) packet) + RTP_PACKET_HEADER_SIZE;
+	int		 buflen;
+
+	buflen = udp_recv(session->rtp_socket, buffer, RTP_MAX_PACKET_LEN);
+	if (rtp_process_recv_data(session, curr_rtp_ts, packet, buflen) < 0)
+	  xfree(packet);
+}
+
+static int validate_rtcp(uint8_t *packet, int len)
+{
+	/* Validity check for a compound RTCP packet. This function returns */
+	/* TRUE if the packet is okay, FALSE if the validity check fails.   */
+        /*                                                                  */
+	/* The following checks can be applied to RTCP packets [RFC1889]:   */
+        /* o RTP version field must equal 2.                                */
+        /* o The payload type field of the first RTCP packet in a compound  */
+        /*   packet must be equal to SR or RR.                              */
+        /* o The padding bit (P) should be zero for the first packet of a   */
+        /*   compound RTCP packet because only the last should possibly     */
+        /*   need padding.                                                  */
+        /* o The length fields of the individual RTCP packets must total to */
+        /*   the overall length of the compound RTCP packet as received.    */
+
+	rtcp_t	*pkt  = (rtcp_t *) packet;
+	rtcp_t	*end  = (rtcp_t *) (((char *) pkt) + len);
+	rtcp_t	*r    = pkt;
+	int	 l    = 0;
+	int	 pc   = 1;
+	int	 p    = 0;
+
+	/* All RTCP packets must be compound packets (RFC1889, section 6.1) */
+	if (((ntohs(pkt->common.length) + 1) * 4) == len) {
+		rtp_message(LOG_WARNING, "Bogus RTCP packet: not a compound packet");
+		return FALSE;
+	}
+
+	/* Check the RTCP version, payload type and padding of the first in  */
+	/* the compund RTCP packet...                                        */
+	if (pkt->common.version != 2) {
+		rtp_message(LOG_WARNING, "Bogus RTCP packet: version number != 2 in the first sub-packet");
+		return FALSE;
+	}
+	if (pkt->common.p != 0) {
+		rtp_message(LOG_WARNING, "Bogus RTCP packet: padding bit is set on first packet in compound");
+		return FALSE;
+	}
+	if ((pkt->common.pt != RTCP_SR) && (pkt->common.pt != RTCP_RR)) {
+		rtp_message(LOG_WARNING, "Bogus RTCP packet: compund packet does not start with SR or RR");
+		return FALSE;
+	}
+
+	/* Check all following parts of the compund RTCP packet. The RTP version */
+	/* number must be 2, and the padding bit must be zero on all apart from  */
+	/* the last packet.                                                      */
+	do {
+		if (p == 1) {
+			rtp_message(LOG_WARNING, "Bogus RTCP packet: padding bit set before last in compound (sub-packet %d)", pc);
+			return FALSE;
+		}
+		if (r->common.p) {
+			p = 1;
+		}
+		if (r->common.version != 2) {
+			rtp_message(LOG_WARNING, "Bogus RTCP packet: version number != 2 in sub-packet %d", pc);
+			return FALSE;
+		}
+		l += (ntohs(r->common.length) + 1) * 4;
+		r  = (rtcp_t *) (((uint32_t *) r) + ntohs(r->common.length) + 1);
+		pc++;	/* count of sub-packets, for debugging... */
+	} while (r < end);
+
+	/* Check that the length of the packets matches the length of the UDP */
+	/* packet in which they were received...                              */
+	if (l != len) {
+		rtp_message(LOG_WARNING, "Bogus RTCP packet: RTCP packet length does not match UDP packet length (%d != %d)", l, len);
+		return FALSE;
+	}
+	if (r != end) {
+		rtp_message(LOG_WARNING, "Bogus RTCP packet: RTCP packet length does not match UDP packet length (%p != %p)", r, end);
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
+static void process_report_blocks(struct rtp *session, rtcp_t *packet, uint32_t ssrc, rtcp_rr *rrp, struct timeval *event_ts)
+{
+	int i;
+	rtp_event	 event;
+	rtcp_rr		*rr;
+
+	/* ...process RRs... */
+	if (packet->common.count == 0) {
+		if (!filter_event(session, ssrc)) {
+			event.ssrc = ssrc;
+			event.type = RX_RR_EMPTY;
+			event.data = NULL;
+			event.ts   = event_ts;
+			session->callback(session, &event);
+		}
+	} else {
+		for (i = 0; i < packet->common.count; i++, rrp++) {
+			rr = (rtcp_rr *) xmalloc(sizeof(rtcp_rr));
+			rr->ssrc          = ntohl(rrp->ssrc);
+			rr->fract_lost    = rrp->fract_lost;	/* Endian conversion handled in the */
+			rr->total_lost    = rrp->total_lost;	/* definition of the rtcp_rr type.  */
+			rr->last_seq      = ntohl(rrp->last_seq);
+			rr->jitter        = ntohl(rrp->jitter);
+			rr->lsr           = ntohl(rrp->lsr);
+			rr->dlsr          = ntohl(rrp->dlsr);
+
+			/* Create a database entry for this SSRC, if one doesn't already exist... */
+			create_source(session, rr->ssrc, FALSE);
+
+			/* Store the RR for later use... */
+			insert_rr(session, ssrc, rr, event_ts);
+
+			/* Call the event handler... */
+			if (!filter_event(session, ssrc)) {
+				event.ssrc = ssrc;
+				event.type = RX_RR;
+				event.data = (void *) rr;
+				event.ts   = event_ts;
+				session->callback(session, &event);
+			}
+		}
+	}
+}
+
+static void process_rtcp_sr(struct rtp *session, rtcp_t *packet, struct timeval *event_ts)
+{
+	uint32_t	 ssrc;
+	rtp_event	 event;
+	rtcp_sr		*sr;
+	source		*s;
+
+	ssrc = ntohl(packet->r.sr.sr.ssrc);
+	s = create_source(session, ssrc, FALSE);
+	if (s == NULL) {
+		rtp_message(LOG_WARNING, "Source 0x%08x invalid, skipping...", ssrc);
+		return;
+	}
+
+	/* Mark as an active sender, if we get a sender report... */
+	if (s->sender == FALSE) {
+		s->sender = TRUE;
+		session->sender_count++;
+	}
+
+	/* Process the SR... */
+	sr = (rtcp_sr *) xmalloc(sizeof(rtcp_sr));
+	sr->ssrc          = ssrc;
+	sr->ntp_sec       = ntohl(packet->r.sr.sr.ntp_sec);
+	sr->ntp_frac      = ntohl(packet->r.sr.sr.ntp_frac);
+	sr->rtp_ts        = ntohl(packet->r.sr.sr.rtp_ts);
+	sr->sender_pcount = ntohl(packet->r.sr.sr.sender_pcount);
+	sr->sender_bcount = ntohl(packet->r.sr.sr.sender_bcount);
+
+	/* Store the SR for later retrieval... */
+	if (s->sr != NULL) {
+		xfree(s->sr);
+	}
+	s->sr = sr;
+	s->last_sr = *event_ts;
+
+	/* Call the event handler... */
+	if (!filter_event(session, ssrc)) {
+		event.ssrc = ssrc;
+		event.type = RX_SR;
+		event.data = (void *) sr;
+		event.ts   = event_ts;
+		session->callback(session, &event);
+	}
+
+	process_report_blocks(session, packet, ssrc, packet->r.sr.rr, event_ts);
+
+	if (((packet->common.count * 6) + 1) < (ntohs(packet->common.length) - 5)) {
+		rtp_message(LOG_NOTICE, "Profile specific SR extension ignored");
+	}
+}
+
+static void process_rtcp_rr(struct rtp *session, rtcp_t *packet, struct timeval *event_ts)
+{
+	uint32_t		 ssrc;
+	source		*s;
+
+	ssrc = ntohl(packet->r.rr.ssrc);
+	s = create_source(session, ssrc, FALSE);
+	if (s == NULL) {
+		rtp_message(LOG_WARNING, "Source 0x%08x invalid, skipping...", ssrc);
+		return;
+	}
+
+	process_report_blocks(session, packet, ssrc, packet->r.rr.rr, event_ts);
+
+	if (((packet->common.count * 6) + 1) < ntohs(packet->common.length)) {
+		rtp_message(LOG_INFO, "Profile specific RR extension ignored");
+	}
+}
+
+static void process_rtcp_sdes(struct rtp *session, rtcp_t *packet, struct timeval *event_ts)
+{
+	int 			count = packet->common.count;
+	struct rtcp_sdes_t 	*sd   = &packet->r.sdes;
+	rtcp_sdes_item 		*rsp; 
+	rtcp_sdes_item		*rspn;
+	rtcp_sdes_item 		*end  = (rtcp_sdes_item *) ((uint32_t *)packet + packet->common.length + 1);
+	source 			*s;
+	rtp_event		 event;
+
+	while (--count >= 0) {
+		rsp = &sd->item[0];
+		if (rsp >= end) {
+			break;
+		}
+		sd->ssrc = ntohl(sd->ssrc);
+		s = create_source(session, sd->ssrc, FALSE);
+		if (s == NULL) {
+			rtp_message(LOG_NOTICE, "Cannot get valid source entry for 0x%08x, skipping...", sd->ssrc);
+		} else {
+			for (; rsp->type; rsp = rspn ) {
+				rspn = (rtcp_sdes_item *)((char*)rsp+rsp->length+2);
+				if (rspn >= end) {
+					rsp = rspn;
+					break;
+				}
+				if (rtp_set_sdes(session, sd->ssrc, rsp->type, rsp->data, rsp->length)) {
+					if (!filter_event(session, sd->ssrc)) {
+						event.ssrc = sd->ssrc;
+						event.type = RX_SDES;
+						event.data = (void *) rsp;
+						event.ts   = event_ts;
+						session->callback(session, &event);
+					}
+				} else {
+					rtp_message(LOG_WARNING, "Invalid sdes item for source 0x%08x, skipping...", sd->ssrc);
+				}
+			}
+		}
+		sd = (struct rtcp_sdes_t *) ((uint32_t *)sd + (((char *)rsp - (char *)sd) >> 2)+1);
+	}
+	if (count >= 0) {
+		rtp_message(LOG_INFO, "Invalid RTCP SDES packet, some items ignored.");
+	}
+}
+
+static void process_rtcp_bye(struct rtp *session, rtcp_t *packet, struct timeval *event_ts)
+{
+	int		 i;
+	uint32_t	 ssrc;
+	rtp_event	 event;
+	source		*s;
+
+	for (i = 0; i < packet->common.count; i++) {
+		ssrc = ntohl(packet->r.bye.ssrc[i]);
+		/* This is kind-of strange, since we create a source we are about to delete. */
+		/* This is done to ensure that the source mentioned in the event which is    */
+		/* passed to the user of the RTP library is valid, and simplify client code. */
+		create_source(session, ssrc, FALSE);
+		/* Call the event handler... */
+		if (!filter_event(session, ssrc)) {
+			event.ssrc = ssrc;
+			event.type = RX_BYE;
+			event.data = NULL;
+			event.ts   = event_ts;
+			session->callback(session, &event);
+		}
+		/* Mark the source as ready for deletion. Sources are not deleted immediately */
+		/* since some packets may be delayed and arrive after the BYE...              */
+		s = get_source(session, ssrc);
+		s->got_bye = TRUE;
+		check_source(s);
+		session->bye_count++;
+	}
+}
+
+static void process_rtcp_app(struct rtp *session, rtcp_t *packet, struct timeval *event_ts)
+{
+	uint32_t         ssrc;
+	rtp_event        event;
+	rtcp_app        *app;
+	source          *s;
+	int              data_len;
+
+	/* Update the database for this source. */
+	ssrc = ntohl(packet->r.app.ssrc);
+	create_source(session, ssrc, FALSE);
+	s = get_source(session, ssrc);
+	if (s == NULL) {
+	        /* This should only occur in the event of database malfunction. */
+	        rtp_message(LOG_NOTICE, "Source 0x%08x invalid, skipping...", ssrc);
+	        return;
+	}
+	check_source(s);
+
+	/* Copy the entire packet, converting the header (only) into host byte order. */
+	app = (rtcp_app *) xmalloc(RTP_MAX_PACKET_LEN);
+	app->version        = packet->common.version;
+	app->p              = packet->common.p;
+	app->subtype        = packet->common.count;
+	app->pt             = packet->common.pt;
+	app->length         = ntohs(packet->common.length);
+	app->ssrc           = ssrc;
+	app->name[0]        = packet->r.app.name[0];
+	app->name[1]        = packet->r.app.name[1];
+	app->name[2]        = packet->r.app.name[2];
+	app->name[3]        = packet->r.app.name[3];
+	data_len            = (app->length - 2) * 4;
+	memcpy(app->data, packet->r.app.data, data_len);
+
+	/* Callback to the application to process the app packet... */
+	if (!filter_event(session, ssrc)) {
+		event.ssrc = ssrc;
+		event.type = RX_APP;
+		event.data = (void *) app;       /* The callback function MUST free this! */
+		event.ts   = event_ts;
+		session->callback(session, &event);
+	}
+}
+
+void rtp_process_ctrl(struct rtp *session, uint8_t *buffer, int buflen)
+{
+	/* This routine processes incoming RTCP packets */
+	rtp_event	 event;
+	struct timeval	 event_ts;
+	rtcp_t		*packet;
+	int		 first;
+	uint32_t	 packet_ssrc = rtp_my_ssrc(session);
+
+	gettimeofday(&event_ts, NULL);
+	if (buflen > 0) {
+		if (session->encryption_enabled)
+		{
+			/* Decrypt the packet... */
+			(session->decrypt_func)(session->encrypt_userdata, buffer, &buflen);
+			buffer += 4;	/* Skip the random prefix... */
+			buflen -= 4;
+		}
+		if (validate_rtcp(buffer, buflen)) {
+			first  = TRUE;
+			packet = (rtcp_t *) buffer;
+			while (packet < (rtcp_t *) (buffer + buflen)) {
+				switch (packet->common.pt) {
+					case RTCP_SR:
+						if (first && !filter_event(session, ntohl(packet->r.sr.sr.ssrc))) {
+							event.ssrc  = ntohl(packet->r.sr.sr.ssrc);
+							event.type  = RX_RTCP_START;
+							event.data  = &buflen;
+							event.ts    = &event_ts;
+							packet_ssrc = event.ssrc;
+							session->callback(session, &event);
+						}
+						process_rtcp_sr(session, packet, &event_ts);
+						break;
+					case RTCP_RR:
+						if (first && !filter_event(session, ntohl(packet->r.rr.ssrc))) {
+							event.ssrc  = ntohl(packet->r.rr.ssrc);
+							event.type  = RX_RTCP_START;
+							event.data  = &buflen;
+							event.ts    = &event_ts;
+							packet_ssrc = event.ssrc;
+							session->callback(session, &event);
+						}
+						process_rtcp_rr(session, packet, &event_ts);
+						break;
+					case RTCP_SDES:
+						if (first && !filter_event(session, ntohl(packet->r.sdes.ssrc))) {
+							event.ssrc  = ntohl(packet->r.sdes.ssrc);
+							event.type  = RX_RTCP_START;
+							event.data  = &buflen;
+							event.ts    = &event_ts;
+							packet_ssrc = event.ssrc;
+							session->callback(session, &event);
+						}
+						process_rtcp_sdes(session, packet, &event_ts);
+						break;
+					case RTCP_BYE:
+						if (first && !filter_event(session, ntohl(packet->r.bye.ssrc[0]))) {
+							event.ssrc  = ntohl(packet->r.bye.ssrc[0]);
+							event.type  = RX_RTCP_START;
+							event.data  = &buflen;
+							event.ts    = &event_ts;
+							packet_ssrc = event.ssrc;
+							session->callback(session, &event);
+						}
+						process_rtcp_bye(session, packet, &event_ts);
+						break;
+				        case RTCP_APP:
+						if (first && !filter_event(session, ntohl(packet->r.app.ssrc))) {
+							event.ssrc  = ntohl(packet->r.app.ssrc);
+							event.type  = RX_RTCP_START;
+							event.data  = &buflen;
+							event.ts    = &event_ts;
+							packet_ssrc = event.ssrc;
+							session->callback(session, &event);
+						}
+					        process_rtcp_app(session, packet, &event_ts);
+						break;
+					default: 
+						rtp_message(LOG_WARNING, "RTCP packet with unknown type (%d) ignored.", packet->common.pt);
+						break;
+				}
+				packet = (rtcp_t *) ((uint8_t *) packet + (4 * (ntohs(packet->common.length) + 1)));
+				first  = FALSE;
+			}
+			if (session->avg_rtcp_size < 0) {
+				/* This is the first RTCP packet we've received, set our initial estimate */
+				/* of the average  packet size to be the size of this packet.             */
+				session->avg_rtcp_size = buflen + RTP_LOWER_LAYER_OVERHEAD;
+			} else {
+				/* Update our estimate of the average RTCP packet size. The constants are */
+				/* 1/16 and 15/16 (section 6.3.3 of draft-ietf-avt-rtp-new-02.txt).       */
+				session->avg_rtcp_size = (0.0625 * (buflen + RTP_LOWER_LAYER_OVERHEAD)) + (0.9375 * session->avg_rtcp_size);
+			}
+			/* Signal that we've finished processing this packet */
+			if (!filter_event(session, packet_ssrc)) {
+				event.ssrc = packet_ssrc;
+				event.type = RX_RTCP_FINISH;
+				event.data = NULL;
+				event.ts   = &event_ts;
+				session->callback(session, &event);
+			}
+		} else {
+			rtp_message(LOG_INFO, "Invalid RTCP packet discarded");
+			session->invalid_rtcp_count++;
+		}
+	}
+}
+
+/**
+ * rtp_recv:
+ * @session: the session pointer (returned by rtp_init())
+ * @timeout: the amount of time that rtcp_recv() is allowed to block
+ * @curr_rtp_ts: the current time expressed in units of the media
+ * timestamp.
+ *
+ * Receive RTP packets and dispatch them.
+ *
+ * Returns: TRUE if data received, FALSE if the timeout occurred.
+ */
+int rtp_recv(struct rtp *session, struct timeval *timeout, uint32_t curr_rtp_ts)
+{
+	check_database(session);
+	udp_fd_zero();
+	udp_fd_set(session->rtp_socket);
+	udp_fd_set(session->rtcp_socket);
+	if (udp_select(timeout) > 0) {
+		if (udp_fd_isset(session->rtp_socket)) {
+			rtp_recv_data(session, curr_rtp_ts);
+		}
+		if (udp_fd_isset(session->rtcp_socket)) {
+                        uint8_t		 buffer[RTP_MAX_PACKET_LEN];
+                        int		 buflen;
+                        buflen = udp_recv(session->rtcp_socket, buffer, RTP_MAX_PACKET_LEN);
+			rtp_process_ctrl(session, buffer, buflen);
+		}
+		check_database(session);
+                return TRUE;
+	}
+	check_database(session);
+        return FALSE;
+}
+
+
+
+/**
+ * rtp_add_csrc:
+ * @session: the session pointer (returned by rtp_init()) 
+ * @csrc: Constributing SSRC identifier
+ * 
+ * Adds @csrc to list of contributing sources used in SDES items.
+ * Used by mixers and transcoders.
+ * 
+ * Return value: TRUE.
+ **/
+int rtp_add_csrc(struct rtp *session, uint32_t csrc)
+{
+	/* Mark csrc as something for which we should advertise RTCP SDES items, */
+	/* in addition to our own SDES.                                          */
+	source	*s;
+
+	check_database(session);
+	s = get_source(session, csrc);
+	if (s == NULL) {
+		s = create_source(session, csrc, FALSE);
+		rtp_message(LOG_INFO, "Created source 0x%08x as CSRC", csrc);
+	}
+	check_source(s);
+	s->should_advertise_sdes = TRUE;
+	session->csrc_count++;
+	rtp_message(LOG_INFO, "Added CSRC 0x%08x as CSRC %d", csrc, session->csrc_count);
+	return TRUE;
+}
+
+/**
+ * rtp_del_csrc:
+ * @session: the session pointer (returned by rtp_init()) 
+ * @csrc: Constributing SSRC identifier
+ * 
+ * Removes @csrc from list of contributing sources used in SDES items.
+ * Used by mixers and transcoders.
+ * 
+ * Return value: TRUE on success, FALSE if @csrc is not a valid source.
+ **/
+int rtp_del_csrc(struct rtp *session, uint32_t csrc)
+{
+	source	*s;
+
+	check_database(session);
+	s = get_source(session, csrc);
+	if (s == NULL) {
+		rtp_message(LOG_ERR, "Invalid source 0x%08x when deleting", csrc);
+		return FALSE;
+	}
+	check_source(s);
+	s->should_advertise_sdes = FALSE;
+	session->csrc_count--;
+	if (session->last_advertised_csrc >= session->csrc_count) {
+                session->last_advertised_csrc = 0;
+        }
+	return TRUE;
+}
+
+/**
+ * rtp_set_sdes:
+ * @session: the session pointer (returned by rtp_init()) 
+ * @ssrc: the SSRC identifier of a participant
+ * @type: the SDES type represented by @value
+ * @value: the SDES description
+ * @length: the length of the description
+ * 
+ * Sets session description information associated with participant
+ * @ssrc.  Under normal circumstances applications always use the
+ * @ssrc of the local participant, this SDES information is
+ * transmitted in receiver reports.  Setting SDES information for
+ * other participants affects the local SDES entries, but are not
+ * transmitted onto the network.
+ * 
+ * Return value: Returns TRUE if participant exists, FALSE otherwise.
+ **/
+int rtp_set_sdes(struct rtp *session, uint32_t ssrc, rtcp_sdes_type type, const char *value, int length)
+{
+	source	*s;
+	char	*v;
+
+	check_database(session);
+
+	s = get_source(session, ssrc);
+	if (s == NULL) {
+		rtp_message(LOG_ERR, "Invalid source 0x%08x when setting", ssrc);
+		return FALSE;
+	}
+	check_source(s);
+
+	v = (char *) xmalloc(length + 1);
+	memset(v, '\0', length + 1);
+	memcpy(v, value, length);
+
+	switch (type) {
+		case RTCP_SDES_CNAME: 
+			if (s->cname) xfree(s->cname);
+			s->cname = v; 
+			break;
+		case RTCP_SDES_NAME:
+			if (s->name) xfree(s->name);
+			s->name = v; 
+			break;
+		case RTCP_SDES_EMAIL:
+			if (s->email) xfree(s->email);
+			s->email = v; 
+			break;
+		case RTCP_SDES_PHONE:
+			if (s->phone) xfree(s->phone);
+			s->phone = v; 
+			break;
+		case RTCP_SDES_LOC:
+			if (s->loc) xfree(s->loc);
+			s->loc = v; 
+			break;
+		case RTCP_SDES_TOOL:
+			if (s->tool) xfree(s->tool);
+			s->tool = v; 
+			break;
+		case RTCP_SDES_NOTE:
+			if (s->note) xfree(s->note);
+			s->note = v; 
+			break;
+		case RTCP_SDES_PRIV:
+			if (s->priv) xfree(s->priv);
+			s->priv = v; 
+			break;
+		default :
+			rtp_message(LOG_NOTICE, "Unknown SDES item (type=%d, value=%s)", type, v);
+                        xfree(v);
+			check_database(session);
+			return FALSE;
+	}
+	check_database(session);
+	return TRUE;
+}
+
+/**
+ * rtp_get_sdes:
+ * @session: the session pointer (returned by rtp_init()) 
+ * @ssrc: the SSRC identifier of a participant
+ * @type: the SDES information to retrieve
+ * 
+ * Recovers session description (SDES) information on participant
+ * identified with @ssrc.  The SDES information associated with a
+ * source is updated when receiver reports are received.  There are
+ * several different types of SDES information, e.g. username,
+ * location, phone, email.  These are enumerated by #rtcp_sdes_type.
+ * 
+ * Return value: pointer to string containing SDES description if
+ * received, NULL otherwise.  
+ */
+const char *rtp_get_sdes(struct rtp *session, uint32_t ssrc, rtcp_sdes_type type)
+{
+	source	*s;
+
+	check_database(session);
+
+	s = get_source(session, ssrc);
+	if (s == NULL) {
+		rtp_message(LOG_ERR, "Invalid source 0x%08x getting sdes", ssrc);
+		return NULL;
+	}
+	check_source(s);
+
+	switch (type) {
+        case RTCP_SDES_CNAME: 
+                return s->cname;
+        case RTCP_SDES_NAME:
+                return s->name;
+        case RTCP_SDES_EMAIL:
+                return s->email;
+        case RTCP_SDES_PHONE:
+                return s->phone;
+        case RTCP_SDES_LOC:
+                return s->loc;
+        case RTCP_SDES_TOOL:
+                return s->tool;
+        case RTCP_SDES_NOTE:
+                return s->note;
+	case RTCP_SDES_PRIV:
+		return s->priv;	
+        default:
+                /* This includes RTCP_SDES_PRIV and RTCP_SDES_END */
+                rtp_message(LOG_WARNING, "Unknown SDES item (type=%d)", type);
+	}
+	return NULL;
+}
+
+/**
+ * rtp_get_sr:
+ * @session: the session pointer (returned by rtp_init()) 
+ * @ssrc: identifier of source
+ * 
+ * Retrieve the latest sender report made by sender with @ssrc identifier.
+ * 
+ * Return value: A pointer to an rtcp_sr structure on success, NULL
+ * otherwise.  The pointer must not be freed.
+ **/
+const rtcp_sr *rtp_get_sr(struct rtp *session, uint32_t ssrc)
+{
+	/* Return the last SR received from this ssrc. The */
+	/* caller MUST NOT free the memory returned to it. */
+	source	*s;
+
+	check_database(session);
+
+	s = get_source(session, ssrc);
+	if (s == NULL) {
+		return NULL;
+	} 
+	check_source(s);
+	return s->sr;
+}
+
+/**
+ * rtp_get_rr:
+ * @session: the session pointer (returned by rtp_init())
+ * @reporter: participant originating receiver report
+ * @reportee: participant included in receiver report
+ * 
+ * Retrieve the latest receiver report on @reportee made by @reporter.
+ * Provides an indication of other receivers reception service.
+ * 
+ * Return value: A pointer to a rtcp_rr structure on success, NULL
+ * otherwise.  The pointer must not be freed.
+ **/
+const rtcp_rr *rtp_get_rr(struct rtp *session, uint32_t reporter, uint32_t reportee)
+{
+	check_database(session);
+        return get_rr(session, reporter, reportee);
+}
+
+/**
+ * rtp_send_data:
+ * @session: the session pointer (returned by rtp_init())
+ * @rtp_ts: The timestamp reflects the sampling instant of the first octet of the RTP data to be sent.  The timestamp is expressed in media units.
+ * @pt: The payload type identifying the format of the data.
+ * @m: Marker bit, interpretation defined by media profile of payload.
+ * @cc: Number of contributing sources (excluding local participant)
+ * @csrc: Array of SSRC identifiers for contributing sources.
+ * @data: The RTP data to be sent.
+ * @data_len: The size @data in bytes.
+ * @extn: Extension data (if present).
+ * @extn_len: size of @extn in bytes.
+ * @extn_type: extension type indicator.
+ * 
+ * Send an RTP packet.  Most media applications will only set the
+ * @session, @rtp_ts, @pt, @m, @data, @data_len arguments.
+ *
+ * Mixers and translators typically set additional contributing sources 
+ * arguments (@cc, @csrc).
+ *
+ * Extensions fields (@extn, @extn_len, @extn_type) are for including
+ * application specific information.  When the widest amount of
+ * inter-operability is required these fields should be avoided as
+ * some applications discard packets with extensions they do not
+ * recognize.
+ * 
+ * Return value: Number of bytes transmitted.
+ **/
+int rtp_send_data(struct rtp *session, uint32_t rtp_ts, int8_t pt, int m, 
+		  int cc, uint32_t* csrc, 
+                  uint8_t *data, int data_len, 
+		  uint8_t *extn, uint16_t extn_len, uint16_t extn_type)
+{
+	int		 buffer_len, i, rc, pad, pad_len;
+	int malloc_len;
+	uint8_t		*buffer;
+	rtp_packet	*packet;
+
+	check_database(session);
+
+	ASSERT(data_len > 0);
+
+	buffer_len = data_len + 12 + (4 * cc);
+	if (extn != NULL) {
+		buffer_len += (extn_len + 1) * 4;
+	}
+
+	/* Do we need to pad this packet to a multiple of 64 bits? */
+	/* This is only needed if encryption is enabled, since DES */
+	/* only works on multiples of 64 bits. We just calculate   */
+	/* the amount of padding to add here, so we can reserve    */
+	/* space - the actual padding is added later.              */
+	pad     = FALSE;
+	pad_len = 0;
+	if (session->encryption_enabled) {
+	  if ((session->encryption_pad_length != 0) &&
+	      ((buffer_len % session->encryption_pad_length) != 0)) {
+	    pad         = TRUE;
+	    pad_len     = session->encryption_pad_length - (buffer_len % session->encryption_pad_length);
+	    buffer_len += pad_len; 
+	    ASSERT((buffer_len % session->encryption_pad_length) == 0);
+	  } 
+	  malloc_len = buffer_len;
+	  malloc_len = buffer_len + session->encryption_lenadd;
+	} else
+	  malloc_len = buffer_len;
+
+	/* Allocate memory for the packet... */
+	buffer     = (uint8_t *) xmalloc(malloc_len + RTP_PACKET_HEADER_SIZE);
+	packet     = (rtp_packet *) buffer;
+
+	/* These are internal pointers into the buffer... */
+	packet->rtp_csrc = (uint32_t *) (buffer + RTP_PACKET_HEADER_SIZE + 12);
+	packet->rtp_extn = (uint8_t  *) (buffer + RTP_PACKET_HEADER_SIZE + 12 + (4 * cc));
+	packet->rtp_data = (uint8_t  *) (buffer + RTP_PACKET_HEADER_SIZE + 12 + (4 * cc));
+	if (extn != NULL) {
+		packet->rtp_data += (extn_len + 1) * 4;
+	}
+	/* ...and the actual packet header... */
+	packet->rtp_pak_v    = 2;
+	packet->rtp_pak_p    = pad;
+	packet->rtp_pak_x    = (extn != NULL);
+	packet->rtp_pak_cc   = cc;
+	packet->rtp_pak_m    = m;
+	packet->rtp_pak_pt   = pt;
+	packet->rtp_pak_seq  = htons(session->rtp_seq++);
+	packet->rtp_pak_ts   = htonl(rtp_ts);
+	packet->rtp_pak_ssrc = htonl(rtp_my_ssrc(session));
+	/* ...now the CSRC list... */
+	for (i = 0; i < cc; i++) {
+		packet->rtp_csrc[i] = htonl(csrc[i]);
+	}
+	/* ...a header extension? */
+	if (extn != NULL) {
+		/* We don't use the packet->extn_type field here, that's for receive only... */
+		uint16_t *base = (uint16_t *) packet->rtp_extn;
+		base[0] = htons(extn_type);
+		base[1] = htons(extn_len);
+		memcpy(packet->rtp_extn + 4, extn, extn_len * 4);
+	}
+	/* ...and the media data... */
+	memcpy(packet->rtp_data, data, data_len);
+	/* ...and any padding... */
+	if (pad) {
+		for (i = 0; i < pad_len; i++) {
+			buffer[buffer_len + RTP_PACKET_HEADER_SIZE - pad_len + i] = 0;
+		}
+		buffer[buffer_len + RTP_PACKET_HEADER_SIZE - 1] = (uint8_t) pad_len;
+	}
+#if 0	
+	{
+	  chk_header *ch;
+	  ch = ((chk_header *)buffer) - 1;
+	  if (chk_header_okay(ch) == FALSE) {
+	    printf("header is not okay\n");
+	  } else {
+	    printf("Header is okay\n");
+	  }
+	}
+#endif
+	/* Finally, encrypt if desired... */
+	if (session->encryption_enabled)
+	{
+	  if (session->encryption_pad_length != 0) {
+		ASSERT((buffer_len % session->encryption_pad_length) == 0);
+	  }
+		(session->encrypt_func)(session->encrypt_userdata, buffer + RTP_PACKET_HEADER_SIZE,
+					&buffer_len); 
+	}
+
+	rc = udp_send(session->rtp_socket, buffer + RTP_PACKET_HEADER_SIZE, buffer_len);
+	xfree(buffer);
+
+	/* Update the RTCP statistics... */
+	session->we_sent     = TRUE;
+	session->rtp_pcount += 1;
+	session->rtp_bcount += buffer_len;
+	gettimeofday(&session->last_rtp_send_time, NULL);
+	
+	check_database(session);
+	return rc;
+}
+
+#ifndef _WIN32
+int rtp_send_data_iov(struct rtp *session, uint32_t rtp_ts, int8_t pt, int m, int cc, uint32_t csrc[], struct iovec *iov, int iov_count, uint8_t *extn, uint16_t extn_len, uint16_t extn_type,
+		      uint16_t seq_num_add)
+{
+	int		 buffer_len, i, rc;
+	uint8_t		*buffer;
+	rtp_packet	*packet;
+	int my_iov_count = iov_count + 1;
+	struct iovec *my_iov;
+
+	/* operation not supported on encrypted sessions */
+	if ((session->encryption_enabled)) {
+		return -1;
+	}
+
+	check_database(session);
+
+	buffer_len = 12 + (4 * cc);
+	if (extn != NULL) {
+		buffer_len += (extn_len + 1) * 4;
+	}
+
+	/* Allocate memory for the packet... */
+	buffer     = (uint8_t *) xmalloc(buffer_len + RTP_PACKET_HEADER_SIZE);
+	packet     = (rtp_packet *) buffer;
+
+	/* These are internal pointers into the buffer... */
+	packet->rtp_csrc = (uint32_t *) (buffer + RTP_PACKET_HEADER_SIZE + 12);
+	packet->rtp_extn = (uint8_t  *) (buffer + RTP_PACKET_HEADER_SIZE + 12 + (4 * cc));
+	packet->rtp_data = (uint8_t  *) (buffer + RTP_PACKET_HEADER_SIZE + 12 + (4 * cc));
+	if (extn != NULL) {
+		packet->rtp_data += (extn_len + 1) * 4;
+	}
+	/* ...and the actual packet header... */
+	packet->rtp_pak_v    = 2;
+	packet->rtp_pak_p    = 0;
+	packet->rtp_pak_x    = (extn != NULL);
+	packet->rtp_pak_cc   = cc;
+	packet->rtp_pak_m    = m;
+	packet->rtp_pak_pt   = pt;
+	packet->rtp_pak_seq  = htons(seq_num_add + session->rtp_seq++);
+	packet->rtp_pak_ts   = htonl(rtp_ts);
+	packet->rtp_pak_ssrc = htonl(rtp_my_ssrc(session));
+	/* ...now the CSRC list... */
+	for (i = 0; i < cc; i++) {
+		packet->rtp_csrc[i] = htonl(csrc[i]);
+	}
+	/* ...a header extension? */
+	if (extn != NULL) {
+		/* We don't use the packet->extn_type field here, that's for receive only... */
+		uint16_t *base = (uint16_t *) packet->rtp_extn;
+		base[0] = htons(extn_type);
+		base[1] = htons(extn_len);
+		memcpy(packet->rtp_extn + 4, extn, extn_len * 4);
+	}
+
+	/* Add the RTP packet header to the beginning of the iov list */
+	my_iov = (struct iovec*)xmalloc(my_iov_count * sizeof(struct iovec));
+
+	my_iov[0].iov_base = buffer + RTP_PACKET_HEADER_SIZE;
+	my_iov[0].iov_len = buffer_len;
+
+	for (i = 1; i < my_iov_count; i++) {
+		my_iov[i].iov_base = iov[i-1].iov_base;
+		my_iov[i].iov_len = iov[i-1].iov_len;
+		buffer_len += my_iov[i].iov_len;
+	}
+
+	/* Send the data */
+	rc = udp_send_iov(session->rtp_socket, my_iov, my_iov_count);
+
+	xfree(buffer);
+	xfree(my_iov);
+
+	/* Update the RTCP statistics... */
+	session->we_sent     = TRUE;
+	session->rtp_pcount += 1;
+	session->rtp_bcount += buffer_len;
+
+	check_database(session);
+	return rc;
+}
+#endif
+
+static int format_report_blocks(rtcp_rr *rrp, int remaining_length, struct rtp *session)
+{
+	int nblocks = 0;
+	int h;
+	source *s;
+	struct timeval now;
+
+	gettimeofday(&now, NULL);
+
+	for (h = 0; h < RTP_DB_SIZE; h++) {
+		for (s = session->db[h]; s != NULL; s = s->next) {
+			check_source(s);
+			if ((nblocks == 31) || (remaining_length < 24)) {
+				break; /* Insufficient space for more report blocks... */
+			}
+			if (s->sender) {
+				/* Much of this is taken from A.3 of draft-ietf-avt-rtp-new-01.txt */
+				int	extended_max      = s->cycles + s->max_seq;
+       				int	expected          = extended_max - s->base_seq + 1;
+       				int	lost              = expected - s->received;
+				int	expected_interval = expected - s->expected_prior;
+       				int	received_interval = s->received - s->received_prior;
+       				int 	lost_interval     = expected_interval - received_interval;
+				int	fraction;
+				uint32_t lsr;
+				uint32_t dlsr;
+
+       				s->expected_prior = expected;
+       				s->received_prior = s->received;
+       				if (expected_interval == 0 || lost_interval <= 0) {
+					fraction = 0;
+       				} else {
+					fraction = (lost_interval << 8) / expected_interval;
+				}
+
+				if (s->sr == NULL) {
+					lsr = 0;
+					dlsr = 0;
+				} else {
+					lsr = ntp64_to_ntp32(s->sr->ntp_sec, s->sr->ntp_frac);
+					dlsr = (uint32_t)(tv_diff(now, s->last_sr) * 65536);
+				}
+				rrp->ssrc       = htonl(s->ssrc);
+				rrp->fract_lost = fraction;
+				rrp->total_lost = lost & 0x00ffffff;
+				rrp->last_seq   = htonl(extended_max);
+				rrp->jitter     = htonl(s->jitter / 16);
+				rrp->lsr        = htonl(lsr);
+				rrp->dlsr       = htonl(dlsr);
+				rrp++;
+				remaining_length -= 24;
+				nblocks++;
+				s->sender = FALSE;
+				session->sender_count--;
+				if (session->sender_count == 0) {
+					break; /* No point continuing, since we've reported on all senders... */
+				}
+			}
+		}
+	}
+	return nblocks;
+}
+
+static uint8_t *format_rtcp_sr(uint8_t *buffer, int buflen, struct rtp *session, uint32_t rtp_ts, uint64_t ntp_ts)
+{
+	/* Write an RTCP SR into buffer, returning a pointer to */
+	/* the next byte after the header we have just written. */
+	rtcp_t		*packet = (rtcp_t *) buffer;
+	int		 remaining_length;
+
+	ASSERT(buflen >= 28);	/* ...else there isn't space for the header and sender report */
+
+	packet->common.version = 2;
+	packet->common.p       = 0;
+	packet->common.count   = 0;
+	packet->common.pt      = RTCP_SR;
+	packet->common.length  = htons(1);
+
+
+	packet->r.sr.sr.ssrc          = htonl(rtp_my_ssrc(session));
+	packet->r.sr.sr.ntp_sec       = htonl((uint32_t)(ntp_ts >> 32));
+	packet->r.sr.sr.ntp_frac      = htonl((uint32_t)(ntp_ts & 0xFFFFFFFF));
+	packet->r.sr.sr.rtp_ts        = htonl(rtp_ts);
+	packet->r.sr.sr.sender_pcount = htonl(session->rtp_pcount);
+	packet->r.sr.sr.sender_bcount = htonl(session->rtp_bcount);
+
+	/* Add report blocks, until we either run out of senders */
+	/* to report upon or we run out of space in the buffer.  */
+	remaining_length = buflen - 28;
+	packet->common.count = format_report_blocks(packet->r.sr.rr, remaining_length, session);
+	packet->common.length = htons((uint16_t) (6 + (packet->common.count * 6)));
+	return buffer + 28 + (24 * packet->common.count);
+}
+
+static uint8_t *format_rtcp_rr(uint8_t *buffer, int buflen, struct rtp *session)
+{
+	/* Write an RTCP RR into buffer, returning a pointer to */
+	/* the next byte after the header we have just written. */
+	rtcp_t		*packet = (rtcp_t *) buffer;
+	int		 remaining_length;
+
+	ASSERT(buflen >= 8);	/* ...else there isn't space for the header */
+
+	packet->common.version = 2;
+	packet->common.p       = 0;
+	packet->common.count   = 0;
+	packet->common.pt      = RTCP_RR;
+	packet->common.length  = htons(1);
+	packet->r.rr.ssrc      = htonl(session->my_ssrc);
+
+	/* Add report blocks, until we either run out of senders */
+	/* to report upon or we run out of space in the buffer.  */
+	remaining_length = buflen - 8;
+	packet->common.count = format_report_blocks(packet->r.rr.rr, remaining_length, session);
+	packet->common.length = htons((uint16_t) (1 + (packet->common.count * 6)));
+	return buffer + 8 + (24 * packet->common.count);
+}
+
+static int add_sdes_item(uint8_t *buf, int buflen, int type, const char *val)
+{
+	/* Fill out an SDES item. It is assumed that the item is a NULL    */
+	/* terminated string.                                              */
+        rtcp_sdes_item *shdr = (rtcp_sdes_item *) buf;
+        int             namelen;
+
+        if (val == NULL) {
+                rtp_message(LOG_ERR, "Cannot format SDES item. type=%d val=%p", type, val);
+                return 0;
+        }
+        shdr->type = type;
+        namelen = strlen(val);
+        shdr->length = namelen;
+        strncpy(shdr->data, val, buflen - 2); /* The "-2" accounts for the other shdr fields */
+        return namelen + 2;
+}
+
+static uint8_t *format_rtcp_sdes(uint8_t *buffer, int buflen, uint32_t ssrc, struct rtp *session)
+{
+        /* From draft-ietf-avt-profile-new-00:                             */
+        /* "Applications may use any of the SDES items described in the    */
+        /* RTP specification. While CNAME information is sent every        */
+        /* reporting interval, other items should be sent only every third */
+        /* reporting interval, with NAME sent seven out of eight times     */
+        /* within that slot and the remaining SDES items cyclically taking */
+        /* up the eighth slot, as defined in Section 6.2.2 of the RTP      */
+        /* specification. In other words, NAME is sent in RTCP packets 1,  */
+        /* 4, 7, 10, 13, 16, 19, while, say, EMAIL is used in RTCP packet  */
+        /* 22".                                                            */
+	uint8_t		*packet = buffer;
+	rtcp_common	*common = (rtcp_common *) buffer;
+	const char	*item;
+	size_t		 remaining_len;
+        int              pad;
+
+	ASSERT(buflen > (int) sizeof(rtcp_common));
+
+	common->version = 2;
+	common->p       = 0;
+	common->count   = 1;
+	common->pt      = RTCP_SDES;
+	common->length  = 0;
+	packet += sizeof(common);
+
+	*((uint32_t *) packet) = htonl(ssrc);
+	packet += 4;
+
+	remaining_len = buflen - (packet - buffer);
+	item = rtp_get_sdes(session, ssrc, RTCP_SDES_CNAME);
+	if ((item != NULL) && ((strlen(item) + (size_t) 2) <= remaining_len)) {
+		packet += add_sdes_item(packet, remaining_len, RTCP_SDES_CNAME, item);
+	}
+
+	remaining_len = buflen - (packet - buffer);
+	item = rtp_get_sdes(session, ssrc, RTCP_SDES_NOTE);
+	if ((item != NULL) && ((strlen(item) + (size_t) 2) <= remaining_len)) {
+		packet += add_sdes_item(packet, remaining_len, RTCP_SDES_NOTE, item);
+	}
+
+	remaining_len = buflen - (packet - buffer);
+	if ((session->sdes_count_pri % 3) == 0) {
+		session->sdes_count_sec++;
+		if ((session->sdes_count_sec % 8) == 0) {
+			/* Note that the following is supposed to fall-through the cases */
+			/* until one is found to send... The lack of break statements in */
+			/* the switch is not a bug.                                      */
+			switch (session->sdes_count_ter % 5) {
+			case 0: item = rtp_get_sdes(session, ssrc, RTCP_SDES_TOOL);
+				if ((item != NULL) && ((strlen(item) + (size_t) 2) <= remaining_len)) {
+					packet += add_sdes_item(packet, remaining_len, RTCP_SDES_TOOL, item);
+					break;
+				}
+			case 1: item = rtp_get_sdes(session, ssrc, RTCP_SDES_EMAIL);
+				if ((item != NULL) && ((strlen(item) + (size_t) 2) <= remaining_len)) {
+					packet += add_sdes_item(packet, remaining_len, RTCP_SDES_EMAIL, item);
+					break;
+				}
+			case 2: item = rtp_get_sdes(session, ssrc, RTCP_SDES_PHONE);
+				if ((item != NULL) && ((strlen(item) + (size_t) 2) <= remaining_len)) {
+					packet += add_sdes_item(packet, remaining_len, RTCP_SDES_PHONE, item);
+					break;
+				}
+			case 3: item = rtp_get_sdes(session, ssrc, RTCP_SDES_LOC);
+				if ((item != NULL) && ((strlen(item) + (size_t) 2) <= remaining_len)) {
+					packet += add_sdes_item(packet, remaining_len, RTCP_SDES_LOC, item);
+					break;
+				}
+			case 4: item = rtp_get_sdes(session, ssrc, RTCP_SDES_PRIV);
+				if ((item != NULL) && ((strlen(item) + (size_t) 2) <= remaining_len)) {
+					packet += add_sdes_item(packet, remaining_len, RTCP_SDES_PRIV, item);
+					break;
+				}
+			}
+			session->sdes_count_ter++;
+		} else {
+			item = rtp_get_sdes(session, ssrc, RTCP_SDES_NAME);
+			if (item != NULL) {
+				packet += add_sdes_item(packet, remaining_len, RTCP_SDES_NAME, item);
+			}
+		}
+	}
+	session->sdes_count_pri++;
+
+	/* Pad to a multiple of 4 bytes... */
+        pad = 4 - ((packet - buffer) & 0x3);
+        while (pad--) {
+               *packet++ = RTCP_SDES_END;
+        }
+
+	common->length = htons((uint16_t) (((int) (packet - buffer) / 4) - 1));
+
+	return packet;
+}
+
+static uint8_t *format_rtcp_app(uint8_t *buffer, int buflen, uint32_t ssrc, rtcp_app *app)
+{
+	/* Write an RTCP APP into the outgoing packet buffer. */
+	rtcp_app    *packet       = (rtcp_app *) buffer;
+	int          pkt_octets   = (app->length + 1) * 4;
+	int          data_octets  =  pkt_octets - 12;
+
+	ASSERT(data_octets >= 0);          /* ...else not a legal APP packet.               */
+	ASSERT(buflen      >  pkt_octets); /* ...else there isn't space for the APP packet. */
+
+	/* Copy one APP packet from "app" to "packet". */
+	packet->version        =   RTP_VERSION;
+	packet->p              =   app->p;
+	packet->subtype        =   app->subtype;
+	packet->pt             =   RTCP_APP;
+	packet->length         =   htons(app->length);
+	packet->ssrc           =   htonl(ssrc);
+	memcpy(packet->name, app->name, 4);
+	memcpy(packet->data, app->data, data_octets);
+
+	/* Return a pointer to the byte that immediately follows the last byte written. */
+	return buffer + pkt_octets;
+}
+
+static void send_rtcp(struct rtp *session,
+		      uint32_t rtp_ts,
+		      uint64_t ntp_ts,
+		     rtcp_app_callback appcallback)
+{
+	/* Construct and send an RTCP packet. The order in which packets are packed into a */
+	/* compound packet is defined by section 6.1 of draft-ietf-avt-rtp-new-03.txt and  */
+	/* we follow the recommended order.                                                */
+	uint8_t	   buffer[RTP_MAX_PACKET_LEN + MAX_ENCRYPTION_PAD + 1024];	/* The +8 is to allow for padding when encrypting */
+	uint8_t	  *ptr = buffer;
+	uint8_t   *old_ptr;
+	uint8_t   *lpt;		/* the last packet in the compound */
+	rtcp_app  *app;
+	unsigned int length, new_length;
+
+	check_database(session);
+	/* If encryption is enabled, add a 32 bit random prefix to the packet */
+	if (session->encryption_enabled)
+	{
+		*((uint32_t *) ptr) = lbl_random();
+		ptr += 4;
+	}
+
+	/* The first RTCP packet in the compound packet MUST always be a report packet...  */
+	if (session->we_sent) {
+		ptr = format_rtcp_sr(ptr, RTP_MAX_PACKET_LEN - (ptr - buffer), session, rtp_ts, ntp_ts);
+	} else {
+		ptr = format_rtcp_rr(ptr, RTP_MAX_PACKET_LEN - (ptr - buffer), session);
+	}
+	/* Add the appropriate SDES items to the packet... This should really be after the */
+	/* insertion of the additional report blocks, but if we do that there are problems */
+	/* with us being unable to fit the SDES packet in when we run out of buffer space  */
+	/* adding RRs. The correct fix would be to calculate the length of the SDES items  */
+	/* in advance and subtract this from the buffer length but this is non-trivial and */
+	/* probably not worth it.                                                          */
+	lpt = ptr;
+	ptr = format_rtcp_sdes(ptr, RTP_MAX_PACKET_LEN - (ptr - buffer), rtp_my_ssrc(session), session);
+
+	/* If we have any CSRCs, we include SDES items for each of them in turn...         */
+	if (session->csrc_count > 0) {
+		ptr = format_rtcp_sdes(ptr, RTP_MAX_PACKET_LEN - (ptr - buffer), next_csrc(session), session);
+	}
+
+	/* Following that, additional RR packets SHOULD follow if there are more than 31   */
+	/* senders, such that the reports do not fit into the initial packet. We give up   */
+	/* if there is insufficient space in the buffer: this is bad, since we always drop */
+	/* the reports from the same sources (those at the end of the hash table).         */
+	while ((session->sender_count > 0)  && ((RTP_MAX_PACKET_LEN - (ptr - buffer)) >= 8)) {
+		lpt = ptr;
+		ptr = format_rtcp_rr(ptr, RTP_MAX_PACKET_LEN - (ptr - buffer), session);
+	}
+
+	/* Finish with as many APP packets as the application will provide. */
+	old_ptr = ptr;
+	if (appcallback) {
+		while ((app = (*appcallback)(session, rtp_ts, RTP_MAX_PACKET_LEN - (ptr - buffer)))) {
+			lpt = ptr;
+			ptr = format_rtcp_app(ptr, RTP_MAX_PACKET_LEN - (ptr - buffer), rtp_my_ssrc(session), app);
+			ASSERT(ptr > old_ptr);
+			old_ptr = ptr;
+			ASSERT(RTP_MAX_PACKET_LEN - (ptr - buffer) >= 0);
+		}
+	}
+
+	/* And encrypt if desired... */
+	if (session->encryption_enabled)
+	  {
+	    if (session->encryption_pad_length != 0) {
+		if (((ptr - buffer) % session->encryption_pad_length) != 0) {
+			/* Add padding to the last packet in the compound, if necessary. */
+			/* We don't have to worry about overflowing the buffer, since we */
+			/* intentionally allocated it 8 bytes longer to allow for this.  */
+			int	padlen = session->encryption_pad_length - ((ptr - buffer) % session->encryption_pad_length);
+			int	i;
+
+			for (i = 0; i < padlen-1; i++) {
+				*(ptr++) = '\0';
+			}
+			*(ptr++) = (uint8_t) padlen;
+			ASSERT(((ptr - buffer) % session->encryption_pad_length) == 0); 
+
+			((rtcp_t *) lpt)->common.p = TRUE;
+			((rtcp_t *) lpt)->common.length = htons((int16_t)(((ptr - lpt) / 4) - 1));
+		}
+	    }
+	    //	    (session->encrypt_func)(session, buffer, ptr - buffer); 
+	    //NORI - FIGURE OUT HOW TO FIX THIS - Change the value of ptr
+	    length = ptr - buffer;//nori
+	    new_length = length;
+	    (session->encrypt_func)(session->encrypt_userdata, buffer, &new_length); //nori
+	    if (new_length != length) ptr += new_length - length;
+	}
+	if (session->rtcp_bw != 0.0) {
+	  (session->rtcp_send)(session, buffer, ptr - buffer);
+	  //(session->rtcp_send)(session, buffer, length);	  
+	}
+
+        /* Loop the data back to ourselves so local participant can */
+        /* query own stats when using unicast or multicast with no  */
+        /* loopback.                                                */
+	//        rtp_process_ctrl(session, buffer, ptr - buffer);
+        rtp_process_ctrl(session, buffer, ptr - buffer);
+	check_database(session);
+}
+
+/**
+ * rtp_send_ctrl:
+ * @session: the session pointer (returned by rtp_init())
+ * @rtp_ts: the current time expressed in units of the media timestamp.
+ * @appcallback: a callback to create an APP RTCP packet, if needed.
+ *
+ * Checks RTCP timer and sends RTCP data when nececessary.  The
+ * interval between RTCP packets is randomized over an interval that
+ * depends on the session bandwidth, the number of participants, and
+ * whether the local participant is a sender.  This function should be
+ * called at least once per second, and can be safely called more
+ * frequently.  
+ */
+void rtp_send_ctrl(struct rtp *session,
+		   uint32_t rtp_ts,
+		   rtcp_app *(*appcallback)(struct rtp *session, uint32_t rtp_ts, int max_size))
+{
+      uint32_t         ntp_sec, ntp_frac;
+      ntp64_time(&ntp_sec, &ntp_frac);
+      rtp_send_ctrl_2(session, rtp_ts, (((uint64_t)ntp_sec) << 32) | ntp_frac, appcallback);
+}
+void rtp_send_ctrl_2(struct rtp *session,
+		     uint32_t rtp_ts,
+		     uint64_t ntp_ts,
+		     rtcp_app *(*appcallback)(struct rtp *session, uint32_t rtp_ts, int max_size))
+{
+	/* Send an RTCP packet, if one is due... */
+	struct timeval	 curr_time;
+
+	check_database(session);
+	gettimeofday(&curr_time, NULL);
+	if (tv_gt(curr_time, session->next_rtcp_send_time)) {
+		/* The RTCP transmission timer has expired. The following */
+		/* implements draft-ietf-avt-rtp-new-02.txt section 6.3.6 */
+		int		 h;
+		source		*s;
+		struct timeval	 new_send_time;
+		double		 new_interval;
+
+		new_interval  = rtcp_interval(session) / (session->csrc_count + 1);
+		new_send_time = session->last_rtcp_send_time;
+		tv_add(&new_send_time, new_interval);
+		if (tv_gt(curr_time, new_send_time)) {
+			send_rtcp(session, rtp_ts, ntp_ts, appcallback);
+			session->initial_rtcp        = FALSE;
+			session->last_rtcp_send_time = curr_time;
+			session->next_rtcp_send_time = curr_time; 
+			tv_add(&(session->next_rtcp_send_time), rtcp_interval(session) / (session->csrc_count + 1));
+			/* We're starting a new RTCP reporting interval, zero out */
+			/* the per-interval statistics.                           */
+			session->sender_count = 0;
+			for (h = 0; h < RTP_DB_SIZE; h++) {
+				for (s = session->db[h]; s != NULL; s = s->next) {
+					check_source(s);
+					s->sender = FALSE;
+				}
+			}
+		} else {
+			session->next_rtcp_send_time = new_send_time;
+		}
+		session->ssrc_count_prev = session->ssrc_count;
+	} 
+	check_database(session);
+}
+
+/**
+ * rtp_update:
+ * @session: the session pointer (returned by rtp_init())
+ *
+ * Trawls through the internal data structures and performs
+ * housekeeping.  This function should be called at least once per
+ * second.  It uses an internal timer to limit the number of passes
+ * through the data structures to once per second, it can be safely
+ * called more frequently.
+ */
+void rtp_update(struct rtp *session)
+{
+	/* Perform housekeeping on the source database... */
+	int	 	 h;
+	source	 	*s, *n;
+	struct timeval	 curr_time;
+	double		 delay;
+
+	gettimeofday(&curr_time, NULL);
+	if (tv_diff(curr_time, session->last_update) < 1.0) {
+		/* We only perform housekeeping once per second... */
+		return;
+	}
+	session->last_update = curr_time;
+
+	/* Update we_sent (section 6.3.8 of RTP spec) */
+	delay = tv_diff(curr_time, session->last_rtp_send_time);
+	if (delay >= 2 * rtcp_interval(session)) {
+		session->we_sent = FALSE;
+	}
+
+	check_database(session);
+
+	for (h = 0; h < RTP_DB_SIZE; h++) {
+		for (s = session->db[h]; s != NULL; s = n) {
+			check_source(s);
+			n = s->next;
+			/* Expire sources which haven't been heard from for a long time.   */
+			/* Section 6.2.1 of the RTP specification details the timers used. */
+
+			/* How long since we last heard from this source?  */
+			delay = tv_diff(curr_time, s->last_active);
+			
+			/* Check if we've received a BYE packet from this source.    */
+			/* If we have, and it was received more than 2 seconds ago   */
+			/* then the source is deleted. The arbitrary 2 second delay  */
+			/* is to ensure that all delayed packets are received before */
+			/* the source is timed out.                                  */
+			if (s->got_bye && (delay > 2.0)) {
+				rtp_message(LOG_INFO, "Deleting source 0x%08x due to reception of BYE %f seconds ago...", s->ssrc, delay);
+				delete_source(session, s->ssrc);
+			}
+
+			/* Sources are marked as inactive if they haven't been heard */
+			/* from for more than 2 intervals (RTP section 6.3.5)        */
+			if ((s->ssrc != rtp_my_ssrc(session)) && (delay > (session->rtcp_interval * 2))) {
+				if (s->sender) {
+					s->sender = FALSE;
+					session->sender_count--;
+				}
+			}
+
+			/* If a source hasn't been heard from for more than 5 RTCP   */
+			/* reporting intervals, we delete it from our database...    */
+			if ((s->ssrc != rtp_my_ssrc(session)) && (delay > (session->rtcp_interval * 5))) {
+				rtp_message(LOG_INFO, "Deleting source 0x%08x due to timeout...", s->ssrc);
+				delete_source(session, s->ssrc);
+			}
+		}
+	}
+
+	/* Timeout those reception reports which haven't been refreshed for a long time */
+	timeout_rr(session, &curr_time);
+	check_database(session);
+}
+
+static void rtp_send_bye_now(struct rtp *session)
+{
+	/* Send a BYE packet immediately. This is an internal function,  */
+	/* hidden behind the rtp_send_bye() wrapper which implements BYE */
+	/* reconsideration for the application.                          */
+	uint8_t	 	 buffer[RTP_MAX_PACKET_LEN + MAX_ENCRYPTION_PAD + 1024];	/* + 8 to allow for padding when encrypting */
+	uint8_t		*ptr = buffer;
+	rtcp_common	*common;
+	unsigned int length, new_length; //nori
+	check_database(session);
+	/* If encryption is enabled, add a 32 bit random prefix to the packet */
+	if (session->encryption_enabled) {
+		*((uint32_t *) ptr) = lbl_random();
+		ptr += 4;
+	}
+
+	ptr    = format_rtcp_rr(ptr, RTP_MAX_PACKET_LEN - (ptr - buffer), session);    
+	common = (rtcp_common *) ptr;
+	
+	common->version = 2;
+	common->p       = 0;
+	common->count   = 1;
+	common->pt      = RTCP_BYE;
+	common->length  = htons(1);
+	ptr += sizeof(common);
+	
+	*((uint32_t *) ptr) = htonl(session->my_ssrc);  
+	ptr += 4;
+	
+	if (session->encryption_enabled) {
+	  	    if (session->encryption_pad_length != 0) {
+		      if (((ptr - buffer) % session->encryption_pad_length) != 0) {
+			/* Add padding to the last packet in the compound, if necessary. */
+			/* We don't have to worry about overflowing the buffer, since we */
+			/* intentionally allocated it 8 bytes longer to allow for this.  */
+			int	padlen = session->encryption_pad_length - ((ptr - buffer) % session->encryption_pad_length);
+			int	i;
+
+			for (i = 0; i < padlen-1; i++) {
+				*(ptr++) = '\0';
+			}
+			*(ptr++) = (uint8_t) padlen;
+
+			common->p      = TRUE;
+			common->length = htons((int16_t)(((ptr - (uint8_t *) common) / 4) - 1));
+		}
+		ASSERT(((ptr - buffer) % session->encryption_pad_length) == 0);
+		    }
+		    //	    (session->encrypt_func)(session, buffer, ptr - buffer);
+		    // NORI - FIX THIS, TOO
+		    new_length = length = ptr - buffer;//nori
+		    (session->encrypt_func)(session->encrypt_userdata, buffer, &new_length);//nori
+		    ptr += new_length - length;
+	}
+		(session->rtcp_send)(session, buffer, ptr - buffer);
+		//(session->rtcp_send)(session, buffer, length);	
+	/* Loop the data back to ourselves so local participant can */
+	/* query own stats when using unicast or multicast with no  */
+	/* loopback.                                                */
+	rtp_process_ctrl(session, buffer, ptr - buffer);
+	//rtp_process_ctrl(session, buffer, length);
+	check_database(session);
+}
+
+/**
+ * rtp_send_bye:
+ * @session: The RTP session
+ *
+ * Sends a BYE message on the RTP session, indicating that this
+ * participant is leaving the session. The process of sending a
+ * BYE may take some time, and this function will block until 
+ * it is complete. During this time, RTCP events are reported 
+ * to the application via the callback function (data packets 
+ * are silently discarded).
+ */
+void rtp_send_bye(struct rtp *session)
+{
+	struct timeval	curr_time, timeout, new_send_time;
+	uint8_t		buffer[RTP_MAX_PACKET_LEN];
+	int		buflen;
+	double		new_interval;
+
+	check_database(session);
+
+	/* "...a participant which never sent an RTP or RTCP packet MUST NOT send  */
+	/* a BYE packet when they leave the group." (section 6.3.7 of RTP spec)    */
+	if ((session->we_sent == FALSE) && (session->initial_rtcp == TRUE)) {
+		rtp_message(LOG_NOTICE, "Silent BYE");
+		return;
+	}
+
+	/* If the session is small, send an immediate BYE. Otherwise, we delay and */
+	/* perform BYE reconsideration as needed.                                  */
+	if ((session->ssrc_count < 50) || session->rtp_socket == NULL) {
+		rtp_send_bye_now(session);
+	} else {
+		gettimeofday(&curr_time, NULL);
+		session->sending_bye         = TRUE;
+		session->last_rtcp_send_time = curr_time;
+		session->next_rtcp_send_time = curr_time; 
+		session->bye_count           = 1;
+		session->initial_rtcp        = TRUE;
+		session->we_sent             = FALSE;
+		session->sender_count        = 0;
+		session->avg_rtcp_size       = 70.0 + RTP_LOWER_LAYER_OVERHEAD;	/* FIXME */
+		tv_add(&session->next_rtcp_send_time, rtcp_interval(session) / (session->csrc_count + 1));
+
+		rtp_message(LOG_DEBUG, "Preparing to send BYE...");
+		while (1) {
+			/* Schedule us to block in udp_select() until the time we are due to send our */
+			/* BYE packet. If we receive an RTCP packet from another participant before   */
+			/* then, we are woken up to handle it...                                      */
+			timeout.tv_sec  = 0;
+			timeout.tv_usec = 0;
+			tv_add(&timeout, tv_diff(session->next_rtcp_send_time, curr_time));
+			udp_fd_zero();
+			udp_fd_set(session->rtcp_socket);
+			if ((udp_select(&timeout) > 0) && udp_fd_isset(session->rtcp_socket)) {
+				/* We woke up because an RTCP packet was received; process it... */
+				buflen = udp_recv(session->rtcp_socket, buffer, RTP_MAX_PACKET_LEN);
+				rtp_process_ctrl(session, buffer, buflen);
+			}
+			/* Is it time to send our BYE? */
+			gettimeofday(&curr_time, NULL);
+			new_interval  = rtcp_interval(session) / (session->csrc_count + 1);
+			new_send_time = session->last_rtcp_send_time;
+			tv_add(&new_send_time, new_interval);
+			if (tv_gt(curr_time, new_send_time)) {
+				rtp_message(LOG_DEBUG, "Sent BYE...");
+				rtp_send_bye_now(session);
+				break;
+			}
+			/* No, we reconsider... */
+			session->next_rtcp_send_time = new_send_time;
+			rtp_message(LOG_INFO, "Reconsidered sending BYE... delay = %f", tv_diff(session->next_rtcp_send_time, curr_time));
+			/* ...and perform housekeeping in the usual manner */
+			rtp_update(session);
+		}
+	}
+}
+
+/**
+ * rtp_done:
+ * @session: the RTP session to finish
+ *
+ * Free the state associated with the given RTP session. This function does 
+ * not send any packets (e.g. an RTCP BYE) - an application which wishes to
+ * exit in a clean manner should call rtp_send_bye() first.
+ */
+void rtp_done(struct rtp *session)
+{
+	int i;
+        source *s, *n;
+
+	check_database(session);
+        /* In delete_source, check database gets called and this assumes */
+        /* first added and last removed is us.                           */
+	for (i = 0; i < RTP_DB_SIZE; i++) {
+                s = session->db[i];
+                while (s != NULL) {
+                        n = s->next;
+                        if (s->ssrc != session->my_ssrc) {
+                                delete_source(session,session->db[i]->ssrc);
+                        }
+                        s = n;
+                }
+	}
+
+	delete_source(session, session->my_ssrc);
+
+	/*
+	 * Introduce a memory leak until we add algorithm-specific
+	 * cleanup functions.
+        if (session->encryption_key != NULL) {
+                xfree(session->encryption_key);
+        }
+	*/
+
+	if (session->rtp_socket != NULL) {
+	  udp_exit(session->rtp_socket);
+	  session->rtp_socket = NULL;
+	}
+	if (session->rtcp_socket != NULL) {
+	  udp_exit(session->rtcp_socket);
+	  session->rtcp_socket = NULL;
+	}
+	xfree(session->addr);
+	xfree(session->opt);
+	xfree(session);
+}
+
+/**
+ * rtp_set_encryption_key:
+ * @session: The RTP session.
+ * @passphrase: The user-provided "pass phrase" to map to an encryption key.
+ *
+ * Converts the user supplied key into a form suitable for use with RTP
+ * and install it as the active key. Passing in NULL as the passphrase
+ * disables encryption. The passphrase is converted into a DES key as
+ * specified in RFC1890, that is:
+ * 
+ *   - convert to canonical form
+ * 
+ *   - derive an MD5 hash of the canonical form
+ * 
+ *   - take the first 56 bits of the MD5 hash
+ * 
+ *   - add parity bits to form a 64 bit key
+ * 
+ * Note that versions of rat prior to 4.1.2 do not convert the passphrase
+ * to canonical form before taking the MD5 hash, and so will
+ * not be compatible for keys which are non-invarient under this step.
+ *
+ * Determine from the user's encryption key which encryption
+ * mechanism we're using. Per the RTP RFC, if the key is of the form
+ *
+ *	string/key
+ *
+ * then "string" is the name of the encryption algorithm,  and
+ * "key" is the key to be used. If no / is present, then the
+ * algorithm is assumed to be (the appropriate variant of) DES.
+ *
+ * Returns: TRUE on success, FALSE on failure.
+ */
+int rtp_set_encryption_key(struct rtp* session, const char *passphrase)
+{
+	char	*canonical_passphrase;
+	u_char	 hash[16];
+	MD5_CTX	 context;
+	char *slash;
+
+	check_database(session);
+        if (session->encryption_algorithm != NULL) {
+		xfree(session->encryption_algorithm);
+ 		session->encryption_algorithm = NULL;
+        }
+
+	if (passphrase == NULL) {
+		/* A NULL passphrase means disable encryption... */
+	    session->encryption_enabled = 0;
+		check_database(session);
+		return TRUE;
+	}
+
+	rtp_message(LOG_DEBUG, "Enabling RTP/RTCP encryption");
+	session->encryption_enabled = 1;
+
+ 	/*
+ 	 * Determine which algorithm we're using.
+ 	 */
+ 
+ 	slash = strchr(passphrase, '/');
+ 	if (slash == 0)
+ 	{
+	    session->encryption_algorithm = xstrdup("DES");
+ 	}
+ 	else
+ 	{
+	    int l = slash - passphrase;
+	    session->encryption_algorithm = xmalloc(l + 1);
+	    strncpy(session->encryption_algorithm, passphrase, l);
+	    session->encryption_algorithm[l] = '\0';
+	    passphrase = slash + 1;
+ 	}
+ 
+ 	rtp_message(LOG_INFO, "Initializing encryption, algorithm is '%s'",
+ 		  session->encryption_algorithm);
+ 
+	/* Step 1: convert to canonical form, comprising the following steps:  */
+	/*   a) convert the input string to the ISO 10646 character set, using */
+	/*      the UTF-8 encoding as specified in Annex P to ISO/IEC          */
+	/*      10646-1:1993 (ASCII characters require no mapping, but ISO     */
+	/*      8859-1 characters do);                                         */
+	/*   b) remove leading and trailing white space characters;            */
+	/*   c) replace one or more contiguous white space characters by a     */
+	/*      single space (ASCII or UTF-8 0x20);                            */
+	/*   d) convert all letters to lower case and replace sequences of     */
+	/*      characters and non-spacing accents with a single character,    */
+	/*      where possible.                                                */
+	canonical_passphrase = (char *) xstrdup(passphrase);	/* FIXME */
+
+	/* Step 2: derive an MD5 hash */
+	MD5Init(&context);
+	MD5Update(&context, (u_char *) canonical_passphrase, strlen(canonical_passphrase));
+	MD5Final((u_char *) hash, &context);
+
+	/* Initialize the encryption algorithm we've received */
+
+	if (strcmp(session->encryption_algorithm, "DES") == 0)
+	{
+		return des_initialize(session, hash, sizeof(hash));
+	}
+	else if (strcmp(session->encryption_algorithm, "Rijndael") == 0)
+	{
+		return rijndael_initialize(session, hash, sizeof(hash));
+	}
+	else
+	{
+		rtp_message(LOG_ERR, "Encryption algorithm \"%s\" not found",
+			  session->encryption_algorithm);
+		return FALSE;
+	}
+}
+
+static int des_initialize(struct rtp *session, u_char *hash, int hashlen)
+{
+	char *key;
+	int	 i, j, k;
+	
+	UNUSED(hashlen);
+
+//	rtp_set_encryption(session,des_encrypt, des_decrypt, session->encrypt_userdata, 0);
+        // changed by Landy
+	rtp_set_encryption(session,des_encrypt, des_decrypt, session, 0);
+	session->encryption_pad_length = 8;
+	//nori
+	//	session->encrypt_func = des_encrypt;
+	//session->decrypt_func = des_decrypt;
+        if (session->crypto_state.des.encryption_key != NULL) {
+                xfree(session->crypto_state.des.encryption_key);
+        }
+        key = session->crypto_state.des.encryption_key = (char *) xmalloc(8);
+	/* Step 3: take first 56 bits of the MD5 hash */
+	key[0] = hash[0];
+	key[1] = hash[0] << 7 | hash[1] >> 1;
+	key[2] = hash[1] << 6 | hash[2] >> 2;
+	key[3] = hash[2] << 5 | hash[3] >> 3;
+	key[4] = hash[3] << 4 | hash[4] >> 4;
+	key[5] = hash[4] << 3 | hash[5] >> 5;
+	key[6] = hash[5] << 2 | hash[6] >> 6;
+	key[7] = hash[6] << 1;
+
+	/* Step 4: add parity bits */
+	for (i = 0; i < 8; ++i) {
+		k = key[i] & 0xfe;
+		j = k;
+		j ^= j >> 4;
+		j ^= j >> 2;
+		j ^= j >> 1;
+		j = (j & 1) ^ 1;
+		key[i] = k | j;
+	}
+printf("aa3\n");
+	check_database(session);
+printf("aa4\n");
+	return TRUE;
+}
+
+//static
+int des_encrypt(void *ifptr, uint8_t *data,
+		unsigned int *size)
+{
+  struct rtp *session = (struct rtp *)ifptr;
+
+  uint8_t 	 initVec[8] = {0,0,0,0,0,0,0,0};
+    qfDES_CBC_e(session->crypto_state.des.encryption_key,
+		data, *size, initVec);
+    return TRUE;
+}
+
+//static 
+int des_decrypt(void *ifptr, uint8_t *data,
+		unsigned int *size)
+{
+  struct rtp *session = (struct rtp *)ifptr;
+  uint8_t 	 initVec[8] = {0,0,0,0,0,0,0,0};
+    qfDES_CBC_d(session->crypto_state.des.encryption_key,
+		data, *size, initVec);
+    return TRUE;
+}
+
+static int rijndael_initialize(struct rtp *session, u_char *hash, int hash_len)
+{
+	int rc;
+	
+//	rtp_set_encryption(session,rijndael_encrypt, rijndael_decrypt, session->encrypt_userdata, 0);
+        // changed by Landy
+	rtp_set_encryption(session,rijndael_encrypt, rijndael_decrypt, session, 0);
+	session->encryption_pad_length = 16;
+	//nori
+	//	session->encrypt_func = rijndael_encrypt;
+	//session->decrypt_func = rijndael_decrypt;
+
+	rc = makeKey(&session->crypto_state.rijndael.keyInstEncrypt,
+		     DIR_ENCRYPT, hash_len * 8, (char *) hash);
+	if (rc < 0)
+	{
+		debug_msg("makeKey failed: %d\n", rc);
+		return FALSE;
+	}
+
+	rc = makeKey(&session->crypto_state.rijndael.keyInstDecrypt,
+		     DIR_DECRYPT, hash_len * 8, (char *) hash);
+	if (rc < 0)
+	{
+		debug_msg("makeKey failed: %d\n", rc);
+		return FALSE;
+	}
+
+	rc = cipherInit(&session->crypto_state.rijndael.cipherInst,
+			MODE_ECB, NULL);
+	if (rc < 0)
+	{
+		debug_msg("cipherInst failed: %d\n", rc);
+		return FALSE;
+	}
+    return TRUE;
+}
+
+static int rijndael_encrypt(void *ifptr, uint8_t *data,
+			    unsigned int *size)
+{
+  struct rtp *session = (struct rtp *)ifptr;
+	int rc;
+
+
+	/*
+	 * Try doing this in place. If it doesn't work that way,
+	 * we'll have to allocate a buffer and copy back.
+	 */
+	rc = blockEncrypt(&session->crypto_state.rijndael.cipherInst,
+			  &session->crypto_state.rijndael.keyInstEncrypt,
+			  data, (*size) * 8, data);
+	return rc;
+}
+
+static int rijndael_decrypt(void *ifptr, uint8_t *data,
+			    unsigned int *size)
+{
+  struct rtp *session = (struct rtp *)ifptr;
+	int rc;
+
+	/*
+	 * Try doing this in place. If it doesn't work that way,
+	 * we'll have to allocate a buffer and copy back.
+	 */
+	rc = blockDecrypt(&session->crypto_state.rijndael.cipherInst,
+			  &session->crypto_state.rijndael.keyInstDecrypt,
+			  data, (*size) * 8, data);
+	return rc;
+}
+
+/**
+ * rtp_get_addr:
+ * @session: The RTP Session.
+ *
+ * Returns: The session's destination address, as set when creating the
+ * session with rtp_init() or rtp_init_if().
+ */
+char *rtp_get_addr(struct rtp *session)
+{
+	check_database(session);
+	return session->addr;
+}
+
+/**
+ * rtp_get_rx_port:
+ * @session: The RTP Session.
+ *
+ * Returns: The UDP port to which this session is bound, as set when
+ * creating the session with rtp_init() or rtp_init_if().
+ */
+uint16_t rtp_get_rx_port(struct rtp *session)
+{
+	check_database(session);
+	return session->rx_port;
+}
+
+/**
+ * rtp_get_tx_port:
+ * @session: The RTP Session.
+ *
+ * Returns: The UDP port to which RTP packets are transmitted, as set
+ * when creating the session with rtp_init() or rtp_init_if().
+ */
+uint16_t rtp_get_tx_port(struct rtp *session)
+{
+	check_database(session);
+	return session->tx_port;
+}
+
+/**
+ * rtp_get_ttl:
+ * @session: The RTP Session.
+ *
+ * Returns: The session's TTL, as set when creating the session with
+ * rtp_init() or rtp_init_if().
+ */
+int rtp_get_ttl(struct rtp *session)
+{
+	check_database(session);
+	return session->ttl;
+}
+
+// test (by nori)
+int rtp_set_encryption(struct rtp *session, rtp_encrypt_func efunc, rtp_decrypt_func dfunc, void *userdata, unsigned int alloc_extra)
+{
+
+	rtp_message(LOG_DEBUG, "Enabling SRTP encryption");
+	session->encryption_enabled = 1;
+	session->encrypt_func = efunc;
+	session->decrypt_func = dfunc;
+       	session->encrypt_userdata = userdata;
+	session->encryption_pad_length = 0;
+	session->encryption_lenadd = alloc_extra;
+	return 0;
+}
+int rtp_get_encryption_enabled(struct rtp *session)
+{
+  return session->encryption_enabled;
+}
+
+socket_udp *get_rtp_data_socket (struct rtp *session)
+{
+  return session->rtp_socket;
+}
+
+socket_udp *get_rtp_rtcp_socket (struct rtp *session)
+{
+  return session->rtcp_socket;
+}

Added: experimental/j/Elphel333/rtp/daemon/rtp/rtp.h
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/rtp.h	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/rtp.h	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,319 @@
+/*
+ * FILE:   rtp.h
+ * AUTHOR: Colin Perkins <c.perkins at cs.ucl.ac.uk>
+ *
+ * $Revision: 1.1.1.1 $ 
+ * $Date: 2005/03/18 09:18:06 $
+ * 
+ * Copyright (c) 1998-2000 University College London
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, is permitted provided that the following conditions 
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by the Computer Science
+ *      Department at University College London.
+ * 4. Neither the name of the University nor of the Department may be used
+ *    to endorse or promote products derived from this software without
+ *    specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef __RTP_H__
+#define __RTP_H__
+#if 0
+#include "config_unix.h"
+#include "config_win32.h"
+#include "net_udp.h"
+#endif
+#ifdef __cplusplus
+extern "C" {
+#endif
+  
+#define RTP_PACKET_HEADER_SIZE	(sizeof(rtp_packet_data))
+#define RTP_VERSION 2
+#define RTP_MAX_PACKET_LEN 1500
+
+
+  // moved here by nori
+typedef int (*rtp_encrypt_func)(void *, uint8_t *, unsigned int *);
+typedef int (*rtp_decrypt_func)(void *, uint8_t *, unsigned int *);
+
+struct rtp;
+
+/* XXX gtkdoc doesn't seem to be able to handle functions that return
+ * struct *'s. */
+typedef struct rtp *rtp_t;
+
+typedef struct rtp_packet_data {
+  struct rtp_packet *rtp_pd_next, *rtp_pd_prev;
+  uint32_t	*rtp_pd_csrc;
+  uint8_t	*rtp_pd_data;
+  int		 rtp_pd_data_len;
+  uint8_t	*rtp_pd_extn;
+  uint16_t	 rtp_pd_extn_len; /* Size of the extension in 32 bit words minus one */
+  uint16_t	 rtp_pd_extn_type;/* Extension type field in the RTP packet header   */
+  int            rtp_pd_buflen; /* received buffer len (w/rtp header) */
+  int            rtp_pd_have_timestamp;
+  uint64_t       rtp_pd_timestamp;
+} rtp_packet_data;
+
+  
+typedef struct rtp_packet_header {
+#ifdef WORDS_BIGENDIAN
+	unsigned short   ph_v:2;	/* packet type                */
+	unsigned short   ph_p:1;	/* padding flag               */
+	unsigned short   ph_x:1;	/* header extension flag      */
+	unsigned short   ph_cc:4;	/* CSRC count                 */
+	unsigned short   ph_m:1;	/* marker bit                 */
+	unsigned short   ph_pt:7;	/* payload type               */
+#else
+	unsigned short   ph_cc:4;	/* CSRC count                 */
+	unsigned short   ph_x:1;	/* header extension flag      */
+	unsigned short   ph_p:1;	/* padding flag               */
+	unsigned short   ph_v:2;	/* packet type                */
+	unsigned short   ph_pt:7;	/* payload type               */
+	unsigned short   ph_m:1;	/* marker bit                 */
+#endif
+	uint16_t          ph_seq;	/* sequence number            */
+	uint32_t          ph_ts;	/* timestamp                  */
+	uint32_t          ph_ssrc;	/* synchronization source     */
+	/* The csrc list, header extension and data follow, but can't */
+	/* be represented in the struct.                              */
+} rtp_packet_header;
+
+#define rtp_next      pd.rtp_pd_next
+#define rtp_prev      pd.rtp_pd_prev
+#define rtp_csrc      pd.rtp_pd_csrc
+#define rtp_data      pd.rtp_pd_data
+#define rtp_data_len  pd.rtp_pd_data_len
+#define rtp_extn      pd.rtp_pd_extn
+#define rtp_extn_len  pd.rtp_pd_extn_len
+#define rtp_extn_type pd.rtp_pd_extn_type
+  
+#define rtp_pak_v    ph.ph_v
+#define rtp_pak_p    ph.ph_p
+#define rtp_pak_x    ph.ph_x
+#define rtp_pak_cc   ph.ph_cc
+#define rtp_pak_m    ph.ph_m
+#define rtp_pak_pt   ph.ph_pt
+#define rtp_pak_seq  ph.ph_seq
+#define rtp_pak_ts   ph.ph_ts
+#define rtp_pak_ssrc ph.ph_ssrc
+
+typedef struct rtp_packet {
+  /* The following are pointers to the data in the packet as    */
+  /* it came off the wire. The packet it read in such that the  */
+  /* header maps onto the latter part of this struct, and the   */
+  /* fields in this first part of the struct point into it. The */
+  /* entire packet can be freed by freeing this struct, without */
+  /* having to free the csrc, data and extn blocks separately.  */
+  rtp_packet_data pd;
+  /* The following map directly onto the RTP packet header...   */
+  rtp_packet_header ph;
+} rtp_packet;
+  
+typedef struct {
+	uint32_t         ssrc;
+	uint32_t         ntp_sec;
+	uint32_t         ntp_frac;
+	uint32_t         rtp_ts;
+	uint32_t         sender_pcount;
+	uint32_t         sender_bcount;
+} rtcp_sr;
+
+typedef struct {
+	uint32_t	ssrc;		/* The ssrc to which this RR pertains */
+#ifdef WORDS_BIGENDIAN
+	uint32_t	fract_lost:8;
+	uint32_t	total_lost:24;
+#else
+	uint32_t	total_lost:24;
+	uint32_t	fract_lost:8;
+#endif	
+	uint32_t	last_seq;
+	uint32_t	jitter;
+	uint32_t	lsr;
+	uint32_t	dlsr;
+} rtcp_rr;
+
+typedef struct {
+#ifdef WORDS_BIGENDIAN
+	unsigned short  version:2;	/* RTP version            */
+	unsigned short  p:1;		/* padding flag           */
+	unsigned short  subtype:5;	/* application dependent  */
+#else
+	unsigned short  subtype:5;	/* application dependent  */
+	unsigned short  p:1;		/* padding flag           */
+	unsigned short  version:2;	/* RTP version            */
+#endif
+	unsigned short  pt:8;		/* packet type            */
+	uint16_t        length;		/* packet length          */
+	uint32_t        ssrc;
+	char            name[4];        /* four ASCII characters  */
+	char            data[1];        /* variable length field  */
+} rtcp_app;
+
+/* rtp_event type values. */
+typedef enum {
+        RX_RTP,
+        RX_SR,
+        RX_RR,
+        RX_SDES,
+        RX_BYE,         /* Source is leaving the session, database entry is still valid                           */
+        SOURCE_CREATED,
+        SOURCE_DELETED, /* Source has been removed from the database                                              */
+        RX_RR_EMPTY,    /* We've received an empty reception report block                                         */
+        RX_RTCP_START,  /* Processing a compound RTCP packet about to start. The SSRC is not valid in this event. */
+        RX_RTCP_FINISH,	/* Processing a compound RTCP packet finished. The SSRC is not valid in this event.       */
+        RR_TIMEOUT,
+        RX_APP
+} rtp_event_type;
+
+typedef struct {
+	uint32_t	 ssrc;
+	rtp_event_type	 type;
+	void		*data;
+	struct timeval	*ts;
+} rtp_event;
+
+/* Callback types */
+typedef void (*rtp_callback)(struct rtp *session, rtp_event *e);
+typedef rtcp_app* (*rtcp_app_callback)(struct rtp *session, uint32_t rtp_ts, int max_size);
+  typedef int (*rtcp_send_packet_t)(void *userdata, uint8_t *buffer, int buflen);
+
+/* SDES packet types... */
+typedef enum  {
+        RTCP_SDES_END   = 0,
+        RTCP_SDES_CNAME = 1,
+        RTCP_SDES_NAME  = 2,
+        RTCP_SDES_EMAIL = 3,
+        RTCP_SDES_PHONE = 4,
+        RTCP_SDES_LOC   = 5,
+        RTCP_SDES_TOOL  = 6,
+        RTCP_SDES_NOTE  = 7,
+        RTCP_SDES_PRIV  = 8
+} rtcp_sdes_type;
+
+typedef struct {
+	uint8_t		type;		/* type of SDES item              */
+	uint8_t		length;		/* length of SDES item (in bytes) */
+	char		data[1];	/* text, not zero-terminated      */
+} rtcp_sdes_item;
+
+/* RTP options */
+typedef enum {
+        RTP_OPT_PROMISC =	    1,
+        RTP_OPT_WEAK_VALIDATION	=   2,
+        RTP_OPT_FILTER_MY_PACKETS = 3
+} rtp_option;
+
+/* API */
+rtp_t		rtp_init(const char *addr, 
+			 uint16_t rx_port, uint16_t tx_port, 
+			 int ttl, double rtcp_bw, 
+			 rtp_callback callback,
+			 uint8_t *userdata);
+  // rtp_init_xmitter - for transmitters - send an RTCP with the first packet
+rtp_t		rtp_init_xmitter(const char *addr, 
+				 uint16_t rx_port, uint16_t tx_port, 
+				 int ttl, double rtcp_bw, 
+				 rtp_callback callback,
+				 uint8_t *userdata);
+rtp_t		rtp_init_if(const char *addr, char *iface, 
+			    uint16_t rx_port, uint16_t tx_port, 
+			    int ttl, double rtcp_bw, 
+			    rtp_callback callback,
+			    uint8_t *userdata,
+			    int dont_init_sockets);
+
+void		 rtp_send_bye(struct rtp *session);
+void		 rtp_done(struct rtp *session);
+
+int 		 rtp_set_option(struct rtp *session, rtp_option optname, int optval);
+int 		 rtp_get_option(struct rtp *session, rtp_option optname, int *optval);
+
+int 		 rtp_recv(struct rtp *session, 
+			  struct timeval *timeout, uint32_t curr_rtp_ts);
+  void rtp_recv_data(struct rtp *session, uint32_t curr_rtp_ts);
+int 		 rtp_send_data(struct rtp *session, 
+			       uint32_t rtp_ts, int8_t pt, int m, 
+			       int cc, uint32_t csrc[], 
+                               uint8_t *data, int data_len, 
+			       uint8_t *extn, uint16_t extn_len, uint16_t extn_type);
+#ifndef _WIN32
+int            rtp_send_data_iov(struct rtp *session, uint32_t rtp_ts, int8_t pt, int m, int cc, uint32_t csrc[], struct iovec *iov, int iov_count, uint8_t *extn, uint16_t extn_len, uint16_t extn_type, uint16_t seq_num_add);
+#endif
+void 		 rtp_send_ctrl(struct rtp *session, uint32_t rtp_ts, 
+			       rtcp_app_callback appcallback);
+void 		 rtp_send_ctrl_2(struct rtp *session, uint32_t rtp_ts,
+				 uint64_t ntp_ts, 
+				 rtcp_app_callback appcallback);
+void 		 rtp_update(struct rtp *session);
+
+uint32_t	 rtp_my_ssrc(struct rtp *session);
+int		 rtp_add_csrc(struct rtp *session, uint32_t csrc);
+int		 rtp_del_csrc(struct rtp *session, uint32_t csrc);
+
+int		 rtp_set_sdes(struct rtp *session, uint32_t ssrc, 
+			      rtcp_sdes_type type, 
+			      const char *value, int length);
+const char	*rtp_get_sdes(struct rtp *session, uint32_t ssrc, rtcp_sdes_type type);
+
+const rtcp_sr	*rtp_get_sr(struct rtp *session, uint32_t ssrc);
+const rtcp_rr	*rtp_get_rr(struct rtp *session, uint32_t reporter, uint32_t reportee);
+
+int              rtp_set_encryption_key(struct rtp *session, const char *passphrase);
+int              rtp_set_my_ssrc(struct rtp *session, uint32_t ssrc);
+
+char 		*rtp_get_addr(struct rtp *session);
+uint16_t	 rtp_get_rx_port(struct rtp *session);
+uint16_t	 rtp_get_tx_port(struct rtp *session);
+int		 rtp_get_ttl(struct rtp *session);
+uint8_t		*rtp_get_userdata(struct rtp *session);
+
+rtp_t		rtp_init_extern_net(const char *addr, 
+				    uint16_t rx_port, uint16_t tx_port, 
+				    int ttl, double rtcp_bw, 
+				    rtp_callback callback,
+				    rtcp_send_packet_t rtcp_send_packet,
+				    uint8_t *userdata);
+  
+int rtp_process_recv_data(struct rtp *session,
+			  uint32_t curr_rtp_ts,
+			  rtp_packet *packet,
+			  int buflen);
+
+void rtp_process_ctrl(struct rtp *session, uint8_t *buffer, int buflen);
+
+  // added by nori
+int rtp_set_encryption(struct rtp *session, rtp_encrypt_func efunc, rtp_decrypt_func, void *userdata, unsigned int);
+int rtp_get_encryption_enabled(struct rtp *session);
+
+typedef struct socket_udp_ socket_udp; 
+
+socket_udp *get_rtp_data_socket(struct rtp *session);
+socket_udp *get_rtp_rtcp_socket(struct rtp *session);
+  
+#ifdef __cplusplus
+}
+#endif
+#endif /* __RTP_H__ */
+

Added: experimental/j/Elphel333/rtp/daemon/rtp/sockstorage.h
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/sockstorage.h	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/sockstorage.h	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 1999 WIDE Project.
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+struct sockaddr_storage {
+#ifdef HAVE_SOCKADDR_SA_LEN
+	uint8_t __ss_len;
+	uint8_t __ss_family;
+	uint8_t fill[126];
+#else
+	uint8_t __ss_family;
+	uint8_t fill[127];
+#endif /* HAVE_SOCKADDR_SA_LEN */
+};

Added: experimental/j/Elphel333/rtp/daemon/rtp/util.c
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/util.c	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/util.c	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,336 @@
+/*
+ * FILE: util.c
+ * PROGRAM: RAT
+ * AUTHOR: Isidor Kouvelas + Colin Perkins + Mark Handley + Orion Hodson
+ * 
+ * $Revision: 1.1.1.1 $
+ * $Date: 2005/03/18 09:18:51 $
+ *
+ * Copyright (c) 1995-2000 University College London
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, is permitted provided that the following conditions 
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by the Computer Science
+ *      Department at University College London
+ * 4. Neither the name of the University nor of the Department may be used
+ *    to endorse or promote products derived from this software without
+ *    specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "config_unix.h"
+#include "config_win32.h"
+#include "debug.h"
+#include "memory.h"
+#include "util.h"
+
+typedef struct s_block {
+	struct s_block  *next;
+} block;
+ 
+#define BLOCK_SIZE            5
+#define SIZE_TO_INDEX(s)      (((s) - 1) >> BLOCK_SIZE)
+#define INDEX_TO_SIZE(i)      (((i) + 1) << BLOCK_SIZE)
+#define MAX_SIZE              (1 << 17)
+#define MAX_INDEX             SIZE_TO_INDEX(MAX_SIZE)
+ 
+static block  *blocks[MAX_INDEX];
+static int     blocks_alloced;
+
+#ifdef DEBUG_MEM
+
+/* Block tracking for when things are going wrong */
+
+#define MAX_BLOCKS_OUT 1280
+static struct iovec blk_out[MAX_BLOCKS_OUT];
+static int          nblks_out;
+
+static int
+get_blk_idx_from_ptr(char *addr)
+{
+        int i;
+        for(i = 0; i < nblks_out; i++) {
+                if (blk_out[i].iov_base == addr) {
+                        return i;
+                }
+        }
+        return -1;
+}
+#endif /* DEBUG_MEM */
+ 
+void *
+_block_alloc(unsigned int size, const char *filen, int line)
+{
+	int         	 i;
+	unsigned int 	*c;
+	char        	*p;
+
+	ASSERT(size > 0);
+	ASSERT(size < MAX_SIZE);
+
+	i = SIZE_TO_INDEX(size);
+ 
+	if (blocks[i] != NULL) {
+		p = (char *)blocks[i];
+		blocks[i] = blocks[i]->next;
+                xclaim((char*)p - 8, filen, line);
+	} else {
+#ifdef DEBUG_MEM_BREAK
+                /* This can only go here if this file is merged with memory.c! [oh] */
+                mem_item[naddr].blen = size;
+#endif /* DEBUG_MEM_BREAK */
+		p = (char *) _xmalloc(INDEX_TO_SIZE(i) + 8,filen,line);
+		*((int *)p) = INDEX_TO_SIZE(i);
+		p += 8;
+                blocks_alloced++;
+	}
+	c = (unsigned int *)((char *)p - 8);
+	if (size > *c) {
+		fprintf(stderr, "block_alloc: block is too small %d %d!\n", size, *c);
+	}
+#ifdef DEBUG_MEM
+        if (blocks_alloced == MAX_BLOCKS_OUT) {
+                debug_msg("Too many blocks allocated.\n");
+                xmemdist(stderr);
+                xmemdmp();
+        }
+
+        blk_out[nblks_out].iov_base = (char*)c;
+        blk_out[nblks_out].iov_len  = size;
+        nblks_out++;
+#endif /* DEBUG_MEM */
+	c++;
+	*c = size;
+	ASSERT(p != NULL);
+	return (void*)p;
+}
+
+void
+block_trash_check()
+{
+#ifdef DEBUG_MEM
+        int i,n,*c;
+        block *b;
+
+        for(i = 0; i<MAX_INDEX;i++) {
+                b = blocks[i];
+                n = 0;
+                while(b) {
+                        b = b->next;
+                        ASSERT(n++ < blocks_alloced);
+                }
+        }
+        for (i = 0; i<nblks_out; i++) {
+                c = (int*)blk_out[i].iov_base;
+                c++;
+                ASSERT((unsigned int)*c == (unsigned int)blk_out[i].iov_len);
+        }
+#endif  /* DEBUG_MEM */
+}
+
+void
+block_check(char *p)
+{
+#ifdef DEBUG_MEM
+        char *blk_base;
+        ASSERT(p!=NULL);
+        blk_base = p-8;
+        ASSERT(get_blk_idx_from_ptr(blk_base) != -1);
+#endif /* DEBUG_MEM */
+        UNUSED(p);
+}
+ 
+void
+_block_free(void *p, int size, int line)
+{
+	int     i, *c;
+#ifdef DEBUG_MEM
+        block *bp;
+        int    n;
+#endif /* DEBUG_MEM */
+        UNUSED(line);
+
+	c = (int *)((char *)p - 8);
+
+#ifdef DEBUG_MEM
+        n = get_blk_idx_from_ptr((char*)c);
+        if (n == -1) {
+                debug_msg("Freeing block (addr 0x%x, %d bytes) that was not allocated with block_alloc(?)\n", (int)c, *(c+1));
+                xfree(c);
+                ASSERT(n != -1);
+        }
+#endif
+
+	if (size > *c) {
+		fprintf(stderr, "block_free: block was too small! %d %d\n", size, *c);
+	}
+	c++;
+	if (size != *c) {
+		fprintf(stderr, "block_free: Incorrect block size given! %d %d\n", size, *c);
+		ASSERT(size == *c);
+	}
+ 
+	i = SIZE_TO_INDEX(size);
+#ifdef DEBUG_MEM
+        bp = blocks[i];
+        n = 0;
+        while(bp) {
+                if (bp == (block*)p) {
+                        debug_msg("already freed line %d\n", *((int *)p+1));
+                        ASSERT(0);
+                }
+                bp = bp->next;
+                n++;
+        }
+        if (i >= 4) {
+                *((int*)p+1) = line;
+        }
+#endif /* DEBUG_MEM */
+	((block *)p)->next = blocks[i];
+	blocks[i] = (block *)p;
+#ifdef DEBUG_MEM
+        c--;
+        i = get_blk_idx_from_ptr((char*)c);
+        ASSERT(i != -1);
+        memmove(blk_out+i, blk_out + i + 1, sizeof(struct iovec) * (nblks_out - i)); 
+        nblks_out --;
+#endif /* DEBUG_MEM */
+}
+
+void
+block_release_all(void)
+{
+    int i;
+    char *p,*q;
+
+    printf("Freeing memory: "); fflush(stdout);
+    for(i=0;i<MAX_INDEX;i++) {
+        p = (char*)blocks[i];
+        while(p) {
+            q = (char*)((block*)p)->next;
+            xfree(p-8);
+	    printf("+"); fflush(stdout);
+            p = q;
+        }
+    }
+    printf("\n");
+}
+
+void
+purge_chars(char *src, char *to_go)
+{
+        char *r, *w;
+        r = w = src;
+        while(*r) {
+                *w = *r;
+                if (!strchr(to_go, (int)*r)) {
+                        w++;
+                }
+                r++;
+        }
+        *w = '\0';
+}
+
+static int
+string_to_words(char *s, char**w, int max_words)
+{
+        int n;
+
+        n = 0;
+        w[0] = (char *) strtok(s, " ");
+        if (w[0] == NULL) {
+                return n;
+        }
+
+        while(++n < max_words) {
+                w[n] = (char *) strtok(NULL, " ");
+                if (w[n] == NULL) break;
+        }
+        return n;
+}
+
+int
+overlapping_words(const char *s1, const char *s2, int max_words)
+{
+        char *c1, *c2, **w1, **w2;
+        int nw1, nw2, nover, i, j;
+
+        c1 = xstrdup(s1);
+        c2 = xstrdup(s2);
+
+        w1 = (char**)xmalloc(sizeof(char*)*max_words);
+        w2 = (char**)xmalloc(sizeof(char*)*max_words);
+
+        nw1 = string_to_words(c1, w1, max_words);
+        nw2 = string_to_words(c2, w2, max_words);
+
+        nover = 0;
+        for(i = 0; i < nw1; i++) {
+                for(j = 0; j < nw2; j++) {
+                        if (strcmp(w1[i], w2[j]) == 0) {
+                                nover++;
+                                continue;
+                        }
+                }
+        }
+
+        xfree(w1);
+        xfree(w2);
+        xfree(c1);
+        xfree(c2);
+        
+        return nover;
+}
+
+int strfind(const char *haystack, const char *needle_start, const char *needle_end)
+{
+	/* Returns TRUE if the string between needle_start and needle_end */
+	/* is found in haystack. The haystack MUST be zero terminated.    */
+	const char	*n, *h;
+	const char	*h_end = haystack + strlen(haystack);
+
+#ifdef DEBUG
+	/* Paranoia check that memory between needle_start and needle_end */
+	/* is a valid string, and doesn't contain a zero byte.            */
+	for (n = needle_start; n != needle_end; n++) {
+		ASSERT(*n != '\0');
+	}
+#endif
+
+	n = needle_start;
+	h = haystack;
+
+	do {
+		if (*n == *h) {
+			n++;
+			h++;
+		} else {
+			h = h - (n - needle_start) + 1;
+			n = needle_start;
+		}
+	} while ((h < h_end) && (n <= needle_end));
+
+	if (n == (needle_end + 1)) {
+		return TRUE;
+	}
+	return FALSE;
+}

Added: experimental/j/Elphel333/rtp/daemon/rtp/util.h
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/util.h	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/util.h	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,72 @@
+/*
+ * FILE:    util.h
+ * PROGRAM: RAT
+ * AUTHOR:  Isidor Kouvelas + Colin Perkins + Orion Hodson
+ *
+ * $Revision: 1.1.1.1 $
+ * $Date: 2005/03/18 09:18:52 $
+ *
+ * Copyright (c) 1995-2000 University College London
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, is permitted provided that the following conditions 
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by the Computer Science
+ *      Department at University College London
+ * 4. Neither the name of the University nor of the Department may be used
+ *    to endorse or promote products derived from this software without
+ *    specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _UTIL_H
+#define _UTIL_H
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+#define block_alloc(x)	_block_alloc(x,__FILE__,__LINE__)
+#define block_free(x,y) _block_free(x,y,__LINE__)
+
+void	*_block_alloc(unsigned size, const char *filen, int line);
+void	 _block_free(void *p, int size, int line);
+void	 block_release_all(void);
+void     block_trash_check(void);
+void     block_check(char *p);
+
+/* purge_chars: removes occurances of chars in to_go from src */
+void purge_chars(char *src, char *to_go); 
+
+/* overlapping_words: returns how many words match in two strings */
+int overlapping_words(const char *s1, const char *s2, int max_words);
+
+/* The strfind() function is mainly for internal use, but might be
+   useful to others... */
+int strfind(const char *haystack, 
+	    const char *needle_start, 
+	    const char *needle_end);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif 

Added: experimental/j/Elphel333/rtp/daemon/rtp/version.h
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/version.h	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/version.h	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1 @@
+#define CCL_VERSION "v1.2.8"

Added: experimental/j/Elphel333/rtp/daemon/rtp/vsnprintf.c
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/vsnprintf.c	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/vsnprintf.c	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,49 @@
+/*
+ * FILE:     vsnprintf.c
+ * AUTHOR:   Colin Perkins
+ * 
+ * Copyright (c) 1997-2001 University College London
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, is permitted provided that the following conditions 
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by the Computer Science
+ *      Department at University College London
+ * 4. Neither the name of the University nor of the Department may be used
+ *    to endorse or promote products derived from this software without
+ *    specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "config_unix.h"
+#include "debug.h"
+#include "vsnprintf.h"
+
+#ifndef HAVE_VSNPRINTF
+int vsnprintf(char *s, size_t buf_size, const char *format, va_list ap)
+{
+	/* Quick hack replacement for vsnprintf... note that this */
+	/* doesn't check for buffer overflows, and so is open to  */
+	/* many really nasty attacks!                             */
+	UNUSED(buf_size);
+        return vsprintf(s,format,ap);
+}
+#endif

Added: experimental/j/Elphel333/rtp/daemon/rtp/vsnprintf.h
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/vsnprintf.h	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/vsnprintf.h	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,14 @@
+#ifndef HAVE_VSNPRINTF
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+int vsnprintf(char *s, size_t buf_size, const char *format, va_list ap);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* HAVE_VSNPRINTF */
+

Added: experimental/j/Elphel333/rtp/daemon/rtp/win32/Makefile.am
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/win32/Makefile.am	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/win32/Makefile.am	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1 @@
+EXTRA_DIST=echo.txt null.txt set.txt

Added: experimental/j/Elphel333/rtp/daemon/rtp/win32/Makefile.in
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/win32/Makefile.in	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/win32/Makefile.in	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,274 @@
+# Makefile.in generated by automake 1.7.2 from Makefile.am.
+# @configure_input@
+
+# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
+# Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+top_builddir = ..
+
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+INSTALL = @INSTALL@
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+host_triplet = @host@
+ACLOCAL = @ACLOCAL@
+AMDEP_FALSE = @AMDEP_FALSE@
+AMDEP_TRUE = @AMDEP_TRUE@
+AMTAR = @AMTAR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+GTKDOC = @GTKDOC@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+OBJEXT = @OBJEXT@
+OPTDOC = @OPTDOC@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+RANLIB = @RANLIB@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_RANLIB = @ac_ct_RANLIB@
+ac_ct_STRIP = @ac_ct_STRIP@
+am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
+am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
+am__include = @am__include@
+am__quote = @am__quote@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+datadir = @datadir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+oldincludedir = @oldincludedir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+EXTRA_DIST = echo.txt null.txt set.txt
+subdir = win32
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/uclconf.h
+CONFIG_CLEAN_FILES =
+DIST_SOURCES =
+DIST_COMMON = Makefile.am Makefile.in
+all: all-am
+
+.SUFFIXES:
+$(srcdir)/Makefile.in:  Makefile.am  $(top_srcdir)/configure.in $(ACLOCAL_M4)
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign  win32/Makefile
+Makefile:  $(srcdir)/Makefile.in  $(top_builddir)/config.status
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+distclean-libtool:
+	-rm -f libtool
+uninstall-info-am:
+tags: TAGS
+TAGS:
+
+ctags: CTAGS
+CTAGS:
+
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+
+top_distdir = ..
+distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+	list='$(DISTFILES)'; for file in $$list; do \
+	  case $$file in \
+	    $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+	    $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+	  esac; \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+	    dir="/$$dir"; \
+	    $(mkinstalldirs) "$(distdir)$$dir"; \
+	  else \
+	    dir=''; \
+	  fi; \
+	  if test -d $$d/$$file; then \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile
+
+installdirs:
+
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-rm -f Makefile $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+
+distclean-am: clean-am distclean-generic distclean-libtool
+
+dvi: dvi-am
+
+dvi-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-exec-am:
+
+install-info: install-info-am
+
+install-man:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-info-am
+
+.PHONY: all all-am check check-am clean clean-generic clean-libtool \
+	distclean distclean-generic distclean-libtool distdir dvi \
+	dvi-am info info-am install install-am install-data \
+	install-data-am install-exec install-exec-am install-info \
+	install-info-am install-man install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-generic \
+	mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am \
+	uninstall-info-am
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:

Added: experimental/j/Elphel333/rtp/daemon/rtp/win32/echo.txt
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/win32/echo.txt	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/win32/echo.txt	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,4 @@
+echo #define CCL_VERSION "v%v%" > version.h
+
+
+

Added: experimental/j/Elphel333/rtp/daemon/rtp/win32/null.txt
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/win32/null.txt	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/win32/null.txt	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,2 @@
+
+

Added: experimental/j/Elphel333/rtp/daemon/rtp/win32/set.txt
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/win32/set.txt	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/win32/set.txt	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1 @@
+set v=
\ No newline at end of file

Added: experimental/j/Elphel333/rtp/daemon/rtp/win32_ver.h
===================================================================
--- experimental/j/Elphel333/rtp/daemon/rtp/win32_ver.h	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/rtp/daemon/rtp/win32_ver.h	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,2 @@
+#define PACKAGE "mpeg4ip"
+#define VERSION "1.0"

Added: experimental/j/Elphel333/shout/.target-makefrag
===================================================================
--- experimental/j/Elphel333/shout/.target-makefrag	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/shout/.target-makefrag	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1 @@
+AXIS_BUILDTYPE=cris-axis-linux-gnu

Added: experimental/j/Elphel333/shout/Makefile
===================================================================
--- experimental/j/Elphel333/shout/Makefile	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/shout/Makefile	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,34 @@
+#
+# Makefile for the Elphel streamer.
+# This probably requires GNU make.
+#
+AXIS_USABLE_LIBS = UCLIBC GLIBC
+include $(AXIS_TOP_DIR)/tools/build/Rules.axis
+
+THEORACOMMON=../common
+THEORACOMMON_OBJS=$(THEORACOMMON)/oggtheora.o $(THEORACOMMON)/utils.o
+
+DEFS   = -DHAVE_CONFIG_H
+CFLAGS = -O2 -W  -Wwrite-strings -Wbad-function-cast -Wmissing-prototypes -Wcast-qual -Wmissing-declarations  $(DEFS) -I$(THEORACOMMON)
+LIBS   = -lm 
+
+LD	= ld-cris
+
+TARGET = TheoraShout
+OBJS   = TheoraShout.o
+SRCS   = $(OBJS:%.o=%.c)
+
+all: $(TARGET)
+
+$(TARGET): $(OBJS) $(THEORACOMMON_OBJS)
+	 $(CC) $(CFLAGS) -o $@ $(OBJS) $(THEORACOMMON_OBJS) $(LIBS)
+	 strip-cris $@
+
+.c.o:
+	$(CC) $(CFLAGS) $(INC) -c $<
+
+$(THEORACOMMON_OBJS): 
+	cd $(THEORACOMMON) && $(MAKE)
+
+clean:
+	-rm -f *.o $(OBJS) $(TARGET)

Added: experimental/j/Elphel333/shout/TheoraShout.c
===================================================================
--- experimental/j/Elphel333/shout/TheoraShout.c	2005-12-01 00:30:28 UTC (rev 10509)
+++ experimental/j/Elphel333/shout/TheoraShout.c	2005-12-01 01:39:59 UTC (rev 10510)
@@ -0,0 +1,633 @@
+/******************************************************************************
+This is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+    
+******************************************************************************/
+// HTTP Ogg Streamer for Elphel Camera 333 input device
+// Copyright (c) 2005 Jan Gerber
+/////////////////////////////////////////////////////////////////////////////
+#include <sys/time.h>
+#include <sys/mman.h>           /* mmap */
+#include <ctype.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <getopt.h>
+
+#include "c313a.h"
+#include "defines.h"
+#include "oggtheora.h"
+
+
+#define D(x) 
+
+#define HDR_INTERVAL   100   // send headers every 4 s for  25 fps
+
+///////////////////// GLOBAL DATA ///////////////////
+int                 mTimeinterval = 40000;  // default for 25 fps
+const char          mmapFileName[]= "/var/tmp/mmap_strm";
+strm_data_t         *strm_data;
+static strm_data_t  strm_data_par;
+int                 hdr_size;
+/////////////// OggTheora data///////////////////////
+int                 kfgshiftm=9;
+len_data_t          packets[6];
+u_int32_t           header_lengths[6];
+uint8_t             *b_headers;
+/////////////////////////////////////////////////////
+
+
+static void
+usage()
+{
+    printf("\n");
+    printf("\tTheora Icecast streamer for Elphel Camera model 333. \n");
+    printf("\tInitial version writed by: Jan Gerber\n");
+
+    printf("\n\tUsage: TheoraIce [-f <fps>] [-a <address>] [-p <port>] [-w] [-h]\n\n");
+    printf("\t\t[-w] - use WEB interface for manage streamer\n\n");
+
+    printf("\t If used WEB interface for manage of streamer, options enumerated\n");
+    printf("\t below can be changed from browser.\n\n");
+    
+    printf("\t\t[-f<fps>] - max values fps(frame per second), default 25.\n");
+    printf("\t\tRange from 1 to 30 fps.\n");
+    printf("\t\t[-a<address>] - Unicast or multicast address for streaming RTP\n");
+    printf("\t\t\tDefault 239.0.0.1\n");
+
+    printf("\t\t[-p<port>] - port for streaming data. Must be EVEN!\n");
+    printf("\t\t\tDefault 20000.\n");
+
+    printf("\t\t[-k<password>] - set encryption mode with key <password> (DES)\n");
+    printf("\t\t[-h]  - this help\n\n");
+  exit(-1);
+}
+
+
+/* ------------------------------------------------------------------------- */
+/* RTP callback related */
+static void
+packet_print(struct rtp *session, rtp_packet *p) 
+{
+    printf("Received data (payload %d timestamp %06d size %d) ", 
+        p->rtp_pak_pt, p->rtp_pak_ts, p->rtp_data_len);
+
+    if (p->rtp_pak_ssrc == rtp_my_ssrc(session)) {
+        /* Unless filtering is enabled we are likely to see
+           out packets if sending to a multicast group. */
+        printf("that I just sent.\n");
+    } else {
+        printf("from SSRC 0x%08x\n", p->rtp_pak_ssrc); 
+    } 
+}
+
+static void
+rtp_event_handler(struct rtp *session, rtp_event *e) 
+{
+    rtp_packet    *p;
+    rtcp_sdes_item    *r;
+
+    switch(e->type) {
+    case RX_RTP: 
+        p = (rtp_packet*)e->data;
+        packet_print(session, p);
+        xfree(p); /* xfree() is mandatory to release RTP packet data */
+        break;
+    case RX_BYE:
+        break;
+    case SOURCE_CREATED:
+        printf("New source created, SSRC = 0x%08x\n", e->ssrc);
+        break;
+    case SOURCE_DELETED:
+        printf("Source deleted, SSRC = 0x%08x\n", e->ssrc);
+        break;
+    case RX_SR:
+    case RX_RR:
+    case RX_RR_EMPTY:
+    case RX_RTCP_START:
+    case RX_RTCP_FINISH:
+           free(e->data);
+        break;
+    case RR_TIMEOUT:
+        printf("RR_TIMEOUT\n");
+           free(e->data);
+        break;
+    case RX_APP:
+        printf("RX_APP\n");
+           free(e->data);
+        break;
+    }
+    fflush(stdout);
+}
+
+
+//////////////////////////////////////////////////////////////////
+// make RTP packets from Theora and send it             //
+//////////////////////////////////////////////////////////////////
+
+static void ogg_TheoraFrame(uint8_t *theora_data, uint32_t len, uint8_t type_frame) {
+        int             header_length;
+        ogg_header_t    header;
+        u_int64_t       granule=0;
+        u_int8_t        *dp;
+
+        header_length= ogg_frame_page (&header,               // [1]
+                                       last_page_flags,       // [2]
+                                       page_size,
+                                       granule,
+                                       stream_serial,
+                                       page++,
+                                       packets[3+frame_type], // [3]
+                                       &frame_length,         // [4]
+                                       &dp                    // [5]
+                                      );
+    /*
+     [1] pointer to the header data
+         (returns - header length in bytes)
+     [2] +1 - continuation, +4 - last (+2 - first)
+         "last" will be masked out if needed
+     [3]  not used if (flags & 1). 
+          frame_header.len is measured in bits, not bytes!
+     [4]  frame data length
+     [5]  pointer to array with frame data(bytes)
+    */
+
+    return;
+}
+
+static void rtp_SendTheoraFrame( struct rtp* session, uint32_t rtp_ts,
+                   uint8_t *theora_data, uint32_t len, uint8_t type_frame) {
+    uint8_t     rtp_packet_buf[BUF_SIZE],*ptr;
+    uint32_t    lastPacket,dataOffset;
+    uint32_t    bytesToSend,payloadLength,payload_len;
+    int         m_first;
+
+    ptr=&rtp_packet_buf[2];
+    rtp_packet_buf[0]=0x0;
+    rtp_packet_buf[1]=type_frame;
+    m_first = 1;
+    lastPacket = 0;    
+    bytesToSend   = len ; 
+    dataOffset    = 0;
+    D(printf("data len %u \n",len);)
+    // first buffer for sending has 2 byets and DATA
+    // we fill buffer manualy
+    if(len <= BUF_SIZE-2) {
+        memcpy(ptr, theora_data, len);
+        rtp_send_data(session, rtp_ts, RTP_PT_THEORA, lastPacket,
+                      0, NULL, rtp_packet_buf , len+2 , NULL, 0, 0);
+        return;
+    }
+    else { 
+        memcpy(ptr,theora_data,BUF_SIZE-2);
+        rtp_send_data(session, rtp_ts, RTP_PT_THEORA, lastPacket,
+                      0, NULL, rtp_packet_buf , BUF_SIZE , NULL, 0, 0);
+    }
+    payloadLength = BUF_SIZE;
+    ptr = theora_data+BUF_SIZE-2;
+    dataOffset = dataOffset + BUF_SIZE -2;    
+
+    do {
+        payload_len  = min(payloadLength,bytesToSend - dataOffset);
+
+        if(  payload_len < payloadLength) 
+            lastPacket = 1;
+        else
+            lastPacket = 0;
+        rtp_send_data(session, rtp_ts, RTP_PT_THEORA, lastPacket,
+                      0, NULL, ptr , payload_len , NULL, 0, 0);
+        ptr += payload_len;
+        dataOffset += payload_len;   
+    } while (dataOffset < bytesToSend);
+}
+
+// SEND  headers to clients. It is Not RFC!!!!!!!!!!!!!!!
+static void rtp_SendTheoraHdrs(struct rtp* session, uint32_t rtp_ts,
+        uint8_t *header_data,uint16_t len) {
+    uint8_t *ptr;
+    int    lastPacket,dataOffset;
+    int    bytesToSend,payloadLength,payload_len;
+    ptr = header_data;
+
+    // it is NOT RFC !!! First byte in packet identification Headers    
+    header_data[0] = 0x80;
+    bytesToSend   = len;
+    dataOffset    = 0;
+    payloadLength = BUF_SIZE;
+    do {
+        payload_len  = min(payloadLength,bytesToSend - dataOffset);
+        if(payload_len < payloadLength) 
+            lastPacket = 1;
+        else
+            lastPacket = 0;
+        //if(lastPacket) hdr_ptr->F_bit=1;
+        rtp_send_data(session, rtp_ts, RTP_PT_THEORA, lastPacket,
+                      0, NULL, ptr + dataOffset , payload_len , NULL, 0, 0);
+        dataOffset += payload_len;
+    } while (dataOffset < bytesToSend);
+}
+
+
+int make_OggTheoraHdrs(const char *headers_filename)
+{
+     FILE      *headers_file;
+     u_int32_t  num_headers;
+     int        i,r;
+     struct stat     f_stat;
+
+    if ((headers_file = fopen(headers_filename, "r"))==NULL) {
+        fprintf(stderr,"error opening file %s for reading - error = %d (%s)\n",
+                        headers_filename,errno,strerror(errno)); 
+        return -1;
+    }
+    if (fread (&num_headers,   4, 1, headers_file)<1) 
+        return -4;
+    if (num_headers!=6) 
+        return -5;
+    if (fread (header_lengths, 4, 6, headers_file)<6) 
+        return -5;
+    if (fread (&kfgshiftm,     4, 1, headers_file)<1) 
+        return -5;
+
+    for (i=0;i<3;i++) 
+        packets[i].len=header_lengths[i]>>3; // now - in bytes
+    for (i=3;i<6;i++) 
+        packets[i].len=header_lengths[i]; // these are needed to be in bits
+    for (i=0;i<6;i++) {
+        header_lengths[i]=(header_lengths[i]+31)>>5;
+        packets[i].data=malloc(header_lengths[i]<<2);
+        if (((r=fread (packets[i].data, 4, header_lengths[i], headers_file))) < (int)header_lengths[i]) {
+           fprintf(stderr, "i=%d, fread returned %d, wanted - %d\n",
+                           i, r,header_lengths[i]);
+           return -6;
+        }     
+    }
+    fclose(headers_file);
+// now some RTP foo that is in no way RFC
+/*
+    stat(headers_filename,&f_stat);
+    hdr_size = f_stat.st_size;
+    //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+    // draft realese - TODO for RFC future
+    b_headers = (uint8_t *)malloc(hdr_size+1);
+    if ((headers_file = fopen(headers_filename, "r"))==NULL) {
+        fprintf(stderr,"error opening file %s for reading - error = %d (%s)\n",
+                       headers_filename,errno,strerror(errno)); 
+        return -1;
+    }
+    // put data into memory buffer
+    if (fread (b_headers+1,   hdr_size, 1, headers_file)<1) 
+        return -7;
+    hdr_size +=1;
+    fclose(headers_file);
+*/
+    return 0;    
+}
+
+static void main_loop(struct rtp* session) {
+    uint64_t    time_frame = 0;
+    uint32_t    rtp_ts,len=0;
+    int         delta, nframe;
+    char        headers_filename[]="/tmp/headers";
+    char        controlfn[]="/dev/ccam_img";
+
+    int         devfd, i;
+    int         acq_data;
+    int         nframes_total, nframes_inter_full, nframes_inter_masked;
+    int         time_slow;
+    u_int8_t    *ccam_dma, *dp = NULL;
+    u_int32_t   *ccam_dma_index;
+    int         circindex_fd;
+    int         circbuf_fd;
+    int         circbuf_size;
+    int         circindex_size;
+ 
+    int         wp,wp0,frame_start = 0,frame_end,frame_type= 0,a_ready;
+    uint32_t    frame_length;
+    int         next_frame_start, frame_no =0,last_page_flags = 0;
+
+    printf("Sending to ");
+    printf("%s port %d (local SSRC = 0x%08x)\n", 
+           rtp_get_addr(session),
+           rtp_get_rx_port(session),
+           rtp_my_ssrc(session));
+
+    a_ready = 0; 
+    circindex_fd = open("/dev/circindex", O_RDWR);
+    if (circindex_fd<0) { // check control OK
+        fprintf(stderr,"Error opening %s\n", "/dev/circindex");
+        return ;
+    }
+    // find total buffer length
+    circindex_size=lseek(circindex_fd,0,2);
+    ccam_dma_index = (u_int32_t *) mmap(0, circindex_size, PROT_READ, MAP_SHARED, circindex_fd, 0);
+    if(ccam_dma_index ==((u_int32_t  *) -1)) {
+        fprintf(stderr,"Error in mmap %s\r\n","/dev/circindex");
+        close(circindex_fd);
+        return ;
+    }
+
+    circbuf_fd = open("/dev/circbuf", O_RDWR);
+    if (circbuf_fd<0) { // check control OK
+        fprintf(stderr,"Error opening %s\n", "/dev/circbuf");
+        close(circindex_fd);
+        return ;
+    }
+    // find total buffer length
+    circbuf_size=lseek(circbuf_fd,0,2);
+    fprintf(stderr,"circbuf stores %d long values (%d bytes)\n",
+                                                (circbuf_size>>2),circbuf_size);
+    ccam_dma = 
+        (u_int8_t *) mmap(0, circbuf_size, PROT_READ, MAP_SHARED, circbuf_fd, 0);
+    if(ccam_dma ==((u_int8_t  *) -1)) {
+        fprintf(stderr,"Error in mmap %s\r\n","/dev/circbuf");
+        close(circindex_fd);
+        close(circbuf_fd);
+        return ;
+    }
+    
+    InitTimer();
+    wp=wp0=0;
+    
+    nframe = HDR_INTERVAL;
+    nframes_total = 0;    // unlimited 
+    nframes_inter_full = 128;
+    nframes_inter_masked = 0;
+    time_slow = (int)(100./strm_data_par.fps);
+    fprintf(stderr,"fps =%f time_slow %d\n",strm_data_par.fps,time_slow);
+    acq_data = ((nframes_total)<<16 ) 
+              | (((nframes_inter_full   > 255)? 
+                255:
+                ((nframes_inter_full   < 0)?0:nframes_inter_full  )) << 8) 
+              | ((nframes_inter_masked > 255)? 
+                255:
+                ((nframes_inter_masked < 0)?0:nframes_inter_masked));
+
+    if(setup_tbl_FPGA( nframes_total, nframes_inter_full,
+                                      nframes_inter_masked, time_slow)<0)
+        return;
+ 
+    if(make_OggTheoraHdrs(headers_filename)<0) {
+        fprintf(stderr,"Error prepare headers while parsing %s\n",headers_filename);
+        free(b_headers);
+        return;
+    }
+    frame_no = 0;
+
+    while (true) {
+        // now - time to start acquisition
+        if ((devfd = open(controlfn, O_RDONLY)) <0) {
+            fprintf(stderr,
+                    "error opening file %s for reading - error = %d (%s)\n",
+                    controlfn,errno,strerror(errno));
+            return ;
+        }
+        // start compression
+        ioctl(devfd, _IO(CMOSCAM_IOCTYPE, IO_CCAM_JPEG_GET_N ), acq_data);
+
+        //now wait for done (or aborted?)
+        while ((i=ioctl(devfd, _IO(CMOSCAM_IOCTYPE, IO_CCAM_MONITOR_SEQ ), 0)) > CAMSEQ_JPEG) {
+            if(strm_data->status == STOP_STREAM ) {
+                break;   // receive command STOP from web interface
+            }
+            // data ready ?    
+            if(wp == 0) {
+                while(frame_no <0)
+                    frame_no = ioctl(devfd, _CCCMD( CCAM_RPARS , P_JPEG_WP), 0)-1;
+                usec_sleep(mTimeinterval>>1);
+                sched_yield();
+                wp=1;
+            }
+
+dark_loop:
+
+            last_page_flags= (ccam_dma_index[frame_no+1]==0xffffffff)?4:0;
+
+            if (last_page_flags == 4) {
+                usec_sleep(mTimeinterval);
+                sched_yield();
+                goto dark_loop;    
+            }
+            //frame_no = ioctl(devfd, _CCCMD( CCAM_RPARS , P_JPEG_WP), 0)-1;
+
+            // soft correction FPS    
+            if(time_frame == 0) 
+                time_frame=GetTimestamp()+1; // when starting - send headers to clients
+
+            // check number of sended data frames
+            // may be we are ready to send Theora Headers?
+            if(nframe >= HDR_INTERVAL) {
+                rtp_SendTheoraHdrs(session,TimestampToRtp(GetTimestamp()),
+                                                    b_headers , hdr_size);
+                nframe = 0;
+            }
+            delta=time_frame-GetTimestamp(); // may be waiting more ?
+  
+            if( delta  > 0) {
+                while(delta > 0){
+                    if(delta <= 10000) 
+                        usec_sleep(0); // sleeps 1 clock tick (10ms)!
+                    else
+                        usec_sleep(delta-10000);
+                    delta-=GetRelativeTime();
+                }
+            }
+            frame_length=(ccam_dma_index[frame_no] & 0xfffffff)-frame_start;
+            //printf("FFFF %u \n",(ccam_dma_index[frame_no] & 0xfffffff)- frame_start);
+
+            //index of next frame in dma
+            next_frame_start=((ccam_dma_index[frame_no] & 0xfffffff)+63) & (~0x1f);
+            frame_type=(ccam_dma_index[frame_no]>>28) & 3;
+            wp0 = ioctl(devfd, _CCCMD( CCAM_RPARS , P_JPEG_WP), 0)-1;
+            if(wp0 < 0) {
+                printf("frame length %d \tframe_no %d = %d \n",
+                                                     frame_length,frame_no,wp0);
+                frame_no=wp0;
+                wp = 0;
+                continue;
+            }
+
+            rtp_ts =TimestampToRtp(time_frame);
+            time_frame+= mTimeinterval; // time start for next frame INTER/INTRA
+            /* Send control packets */
+            rtp_send_ctrl(session, rtp_ts, NULL);
+            rtp_update(session);
+
+            //pointer to next theora frame in camera dma
+            dp=&ccam_dma[frame_start];
+            if((unsigned)frame_length <1000000)
+                rtp_SendTheoraFrame( session, rtp_ts, dp, frame_length, frame_type);
+
+            frame_start=next_frame_start;
+            frame_no++;
+            if(frame_no > wp0)
+               wp = 0;
+
+            nframe++;
+            xmemchk();
+        }
+        if(strm_data->status == STOP_STREAM ) {
+        // stop sencor
+            system("hello -z 0");
+            printf("RTP Streamer stopped \n");
+            break;   // receive command STOP from web interface
+            //ioctl(devfd, _IO(CMOSCAM_IOCTYPE, IO_CCAM_JPEG ), JPEG_CMD_STOP);
+        } // if STOP_STREAM         
+    } // while main    
+//=========================== END MAIN LOOP ============================ 
+}
+
+
+int main(int argc, char *argv[]) 
+{
+    struct rtp  *session = NULL;
+    int         devfd,c,flag,use_web;
+
+    flag = 0;
+    use_web = false;
+    strcpy(strm_data_par.address,"239.0.0.1");
+    strm_data_par.port = 20000;
+    strm_data_par.fps  = 25.;
+    strm_data_par.status   = STOP_STREAM;
+    //strm_data_par.regim    = JPEG_ACCESS_DRV; 
+    //strm_data_par.scanning = STOP_SCANNING;
+    strcpy(strm_data_par.name,"Elphel Camera #1");
+    strcpy(strm_data_par.telephone,"1-800-RTP-HOT-PHONE");
+    strcpy(strm_data_par.toolname,"Elphel Theora Streamer");
+    strcpy(strm_data_par.note,"Draft release ofr RTP Theora");
+    strcpy(strm_data_par.location,"This camera located anywhere");
+    strcpy(strm_data_par.email,"camera at elphel.com");
+    strm_data_par.encrypt_key[0]='\0';
+
+    while(true) {
+        c = getopt(argc, argv, "hwa:p:f:k:");
+        if (c == -1)
+            break;
+     
+        switch (c) {
+            case 'h':
+                flag++;    
+                break;
+            case 'w':
+                use_web = true;     
+                break;
+            case 'a':
+                memset(strm_data_par.address,0,21);
+                strncpy(strm_data_par.address,optarg,20);
+                break;
+            case 'k':
+                memset(strm_data_par.encrypt_key,0,41);
+                strncpy(strm_data_par.encrypt_key,optarg,40);
+                strm_data_par.encryption=1;
+                break;
+            case 'p':
+                strm_data_par.port = atol(optarg);    
+                break;
+            case 'f':
+                strm_data_par.fps = atof(optarg);
+                if(strm_data_par.fps < 0. )
+                    strm_data_par.fps=25.;    
+                break;
+            case '?':
+                flag++;
+                break;
+            default:
+                printf ("?? getopt returned character code 0%o ??\n", c);
+        }
+    }
+    if ((optind < argc)|| flag>0) {
+        usage();
+        exit(1);
+    }
+    if(use_web) {
+        unlink(mmapFileName);
+        // map shared memory for manage this with CGI 
+        // where shared memory opening whith query too
+    
+        devfd = open(mmapFileName,O_RDWR|O_CREAT); 
+        if(devfd == -1) {
+            printf("Error opening %s!\n",mmapFileName);
+        }
+        lseek(devfd,sizeof(strm_data_t),SEEK_SET);
+        write(devfd,"",1);
+        strm_data = (strm_data_t *) mmap(0, sizeof(strm_data_t), 
+                                     PROT_READ|PROT_WRITE, MAP_SHARED, devfd, 0);
+        if((int)strm_data == -1) {
+             fprintf(stderr,"Error in mmap %s\r\n",mmapFileName);
+             close(devfd);
+             unlink(mmapFileName);
+             exit(1);
+        }
+    } 
+    else {
+        strm_data = &strm_data_par;  // use data from local buffer   
+        // not used web - start streamer immediate
+        strm_data_par.status = START_STREAM;
+    }       
+    
+    // OK - init data
+
+    // General LOOP waiting command START
+    while(true) {
+         if(strm_data->status == -1)
+            break;
+         if(strm_data->status == STOP_STREAM ) {
+            //sleep some time and test status again
+            usec_sleep(100000);
+            continue;
+         }
+         printf("\n RTP Streamer for Theora starting...\n");
+
+        mTimeinterval = (int) TimestampTicks/strm_data->fps; // min interval between frames
+        printf("Time frame %u for FPS %f, dest address %s:%d \n\n", mTimeinterval, strm_data->fps, 
+        strm_data->address,strm_data->port);
+        memcpy((void *)&strm_data_par,(void *)strm_data,sizeof(strm_data_t));
+
+        //OK - receive command START streaming    
+        // create session and transmit data    
+        // address,port and fps(soft - not hardware) may be changed
+        // from web interfase
+        session = rtp_init_xmitter( strm_data->address,    /* Host/Group IP address */ 
+               strm_data->port,        /* receive port */
+               strm_data->port,        /* transmit port */
+               16,            /* time-to-live */
+               8000000,        /* B/W estimate */
+               rtp_event_handler,    /* RTP event callback */
+               NULL);        /* App. specific data */
+
+        if (session) {
+             uint32_t   my_ssrc = rtp_my_ssrc(session);
+
+            /* Set stream info here */
+
+            /* Filter out local packets if requested */
+    
+            // Run main loop - get data from buffer and sent RTP packets
+            // while this process not received command stop
+            main_loop(session);
+
+            /* Say bye-bye */
+            rtp_send_bye(session);
+            rtp_done(session);
+            xmemchk();
+        } 
+        else {
+           fprintf(stderr,"Could not initialize session for %s port %d\n", 
+                                            strm_data->address, strm_data->port);
+        }
+  } // general while    
+  return 0;
+}



More information about the commits mailing list